|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package org.gcube.portlets.user.geoportaldataentry.client.ui.edit;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -13,9 +14,11 @@ import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelaz
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV;
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
|
|
|
|
@ -61,6 +64,16 @@ import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
*/
|
|
|
|
|
public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
|
|
private static final String _FORM_WIDTH_FIELDS_SIZE = "730px";
|
|
|
|
|
|
|
|
|
|
private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class);
|
|
|
|
@ -110,14 +123,22 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
private Map<Integer, WorkspaceContentDV> mapForCCUploading = null;
|
|
|
|
|
|
|
|
|
|
private Map<Integer, List<WorkspaceContentDV>> mapWSContentListBox = null;
|
|
|
|
|
|
|
|
|
|
private HandlerManager editorManagerBus;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Instantiates a new update fileset.
|
|
|
|
|
*
|
|
|
|
|
* @param editorManagerBus the editor manager bus
|
|
|
|
|
* @param selectedConcessione the selected concessione
|
|
|
|
|
* @param recordType the record type
|
|
|
|
|
* @param listFileSetPaths the list file set paths
|
|
|
|
|
*/
|
|
|
|
|
public UpdateFileset(BaseConcessioneDV selectedConcessione, RECORD_TYPE recordType, List<String> listFileSetPaths) {
|
|
|
|
|
public UpdateFileset(HandlerManager editorManagerBus, BaseConcessioneDV selectedConcessione, RECORD_TYPE recordType, List<String> listFileSetPaths) {
|
|
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
|
this.editorManagerBus = editorManagerBus;
|
|
|
|
|
this.selectedConcessione = selectedConcessione;
|
|
|
|
|
this.recordType = recordType;
|
|
|
|
|
this.listFileSetPaths = listFileSetPaths;
|
|
|
|
@ -208,11 +229,10 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
dialogConfirm.hide();
|
|
|
|
|
buttonUpdate.setEnabled(false);
|
|
|
|
|
|
|
|
|
|
final DialogInform dialogInf = new DialogInform(null, "Updating Project", "");
|
|
|
|
|
final DialogInform dialogInf = new DialogInform(null, "Updating Project...", "");
|
|
|
|
|
dialogInf.setZIndex(100000);
|
|
|
|
|
dialogInf.showLoader("updating file/s for project: "+fullConcessione.getNome());
|
|
|
|
|
dialogInf.showLoader("Updating file/s for project: "+fullConcessione.getNome());
|
|
|
|
|
//dialogInf.setWidth("400px");
|
|
|
|
|
dialogInf.center();
|
|
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().updateSectionForRecord(
|
|
|
|
|
fullConcessione.getItemId(), fullConcessione.getRecordType(),
|
|
|
|
@ -237,8 +257,11 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
dialogInf.setMsg(result.getNome() + " updated correclty");
|
|
|
|
|
dialogInf.center();
|
|
|
|
|
fullConcessione = result;
|
|
|
|
|
GWT.log("new concessione: "+fullConcessione);
|
|
|
|
|
buttonUpdate.setEnabled(true);
|
|
|
|
|
showUploadFileGUI();
|
|
|
|
|
editorManagerBus.fireEvent(
|
|
|
|
|
new ActionOnItemEvent<ConcessioneDV>(Arrays.asList(fullConcessione), ACTION_ON_ITEM.UPDATED_RECORD));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -268,6 +291,7 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
fieldUploadWidget = null;
|
|
|
|
|
pathIndex = null;
|
|
|
|
|
mapForCCUploading = null;
|
|
|
|
|
mapWSContentListBox = null;
|
|
|
|
|
|
|
|
|
|
// listBoxIndex.clear();
|
|
|
|
|
cgSelectFile.setVisible(true);
|
|
|
|
@ -275,60 +299,76 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
ListBox listBoxContentIndex = new ListBox();
|
|
|
|
|
listBoxContentIndex.setWidth(_FORM_WIDTH_FIELDS_SIZE);
|
|
|
|
|
listBoxContentIndex.addItem("Select a content...");
|
|
|
|
|
|
|
|
|
|
if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) {
|
|
|
|
|
String section = null;
|
|
|
|
|
Integer posizIndex = 0;
|
|
|
|
|
if (listBoxPaths.getSelectedItemText().contains(SECTION_ABSTRACT_RELAZIONE)) {
|
|
|
|
|
section = SECTION_ABSTRACT_RELAZIONE;
|
|
|
|
|
AbstractRelazioneScavoDV ar = fullConcessione.getAbstractRelazioneScavo();
|
|
|
|
|
|
|
|
|
|
if (ar == null) {
|
|
|
|
|
showMessage("abstract_relazione" + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
showMessage(SECTION_ABSTRACT_RELAZIONE + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
// pathIndex = 0;
|
|
|
|
|
// showNewFileUpload();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, "abstract_relazione", posizIndex, ar.getTitolo(),
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, ar.getTitolo(),
|
|
|
|
|
ar.getListWsContent());
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains("immagini")) {
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains(SECTION_IMMAGINI)) {
|
|
|
|
|
section = SECTION_IMMAGINI;
|
|
|
|
|
List<UploadedImageDV> listImmagini = fullConcessione.getImmaginiRappresentative();
|
|
|
|
|
if (listImmagini == null || listImmagini.isEmpty()) {
|
|
|
|
|
showMessage("immagini" + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
showMessage(SECTION_IMMAGINI + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
// pathIndex = 0;
|
|
|
|
|
// showNewFileUpload();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
|
|
|
|
|
for (UploadedImageDV uploadedImageDV : listImmagini) {
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, "immagini", posizIndex, uploadedImageDV.getTitolo(),
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, uploadedImageDV.getTitolo(),
|
|
|
|
|
uploadedImageDV.getListWsContent());
|
|
|
|
|
posizIndex++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains("relazione")) {
|
|
|
|
|
RelazioneScavoDV realzione = fullConcessione.getRelazioneScavo();
|
|
|
|
|
if (realzione == null || realzione.getListWsContent() == null) {
|
|
|
|
|
showMessage("relazione" + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
} 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();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, "relazione", posizIndex, realzione.getTitolo(),
|
|
|
|
|
realzione.getListWsContent());
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains("posizionamentoScavo")) {
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, relazioneScavo.getTitolo(),
|
|
|
|
|
relazioneScavo.getListWsContent());
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains(SECTION_POSIZIONAMENTO_SCAVO)) {
|
|
|
|
|
section = SECTION_POSIZIONAMENTO_SCAVO;
|
|
|
|
|
LayerConcessioneDV posiz = fullConcessione.getPosizionamentoScavo();
|
|
|
|
|
if (posiz == null || posiz.getListWsContent() == null || posiz.getListWsContent().isEmpty()) {
|
|
|
|
|
showMessage("posizionamentoScavo" + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
if (posiz == null) {
|
|
|
|
|
showMessage(SECTION_POSIZIONAMENTO_SCAVO + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
// pathIndex = 0;
|
|
|
|
|
// showNewFileUpload();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, "posizionamentoScavo", posizIndex, posiz.getTitolo(),
|
|
|
|
|
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, posiz.getTitolo(),
|
|
|
|
|
posiz.getListWsContent());
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains("piante")) {
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains(SECTION_PIANTE)) {
|
|
|
|
|
section = SECTION_PIANTE;
|
|
|
|
|
List<LayerConcessioneDV> piante = fullConcessione.getPianteFineScavo();
|
|
|
|
|
if (piante == null || piante.isEmpty()) {
|
|
|
|
|
showMessage("piante" + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
showMessage(SECTION_PIANTE + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
// pathIndex = 0;
|
|
|
|
|
// showNewFileUpload();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
|
|
|
|
|
for (LayerConcessioneDV lcDV : piante) {
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, "piante", posizIndex, lcDV.getTitolo(),
|
|
|
|
|
fillListBoxToBeReplaced(listBoxContentIndex, SECTION_PIANTE, posizIndex, lcDV.getTitolo(),
|
|
|
|
|
lcDV.getListWsContent());
|
|
|
|
|
posizIndex++;
|
|
|
|
|
}
|
|
|
|
@ -348,13 +388,21 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
private void fillListBoxToBeReplaced(ListBox listBoxContentIndex, String section, int posizIndex, String title,
|
|
|
|
|
List<WorkspaceContentDV> listWSC) {
|
|
|
|
|
GWT.log("fillListBoxToBeReplaced called, posizIndex: "+posizIndex+", listWSC: "+listWSC);
|
|
|
|
|
|
|
|
|
|
if (listWSC == null || listWSC.isEmpty()) {
|
|
|
|
|
showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING);
|
|
|
|
|
showMessage(section + " does not contain file!", LabelType.WARNING);
|
|
|
|
|
pathIndex = posizIndex;
|
|
|
|
|
showNewFileUpload();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(mapWSContentListBox==null) {
|
|
|
|
|
mapWSContentListBox = new HashMap<Integer, List<WorkspaceContentDV>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listBoxContentIndex.addItem(title, posizIndex + "");
|
|
|
|
|
mapWSContentListBox.put(posizIndex, listWSC);
|
|
|
|
|
|
|
|
|
|
// adding handler once
|
|
|
|
|
if (posizIndex == 0) {
|
|
|
|
@ -363,13 +411,15 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onChange(ChangeEvent event) {
|
|
|
|
|
|
|
|
|
|
GWT.log("listBoxContentIndex changed, posizIndex: "+posizIndex);
|
|
|
|
|
|
|
|
|
|
if (placeholderListBoxIndex) {
|
|
|
|
|
listBoxContentIndex.removeItem(0); // this is the placeholder, removing it once
|
|
|
|
|
placeholderListBoxIndex = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showFileBrowseInteraction(listBoxContentIndex.getSelectedIndex(), listWSC);
|
|
|
|
|
int selectedIndex = listBoxContentIndex.getSelectedIndex();
|
|
|
|
|
GWT.log("selected index: "+selectedIndex);
|
|
|
|
|
showFileBrowseInteraction(selectedIndex, mapWSContentListBox.get(selectedIndex));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -380,6 +430,8 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
private void showFileBrowseInteraction(int pathContentIndex, List<WorkspaceContentDV> listWSC) {
|
|
|
|
|
uploadFileContainer.clear();
|
|
|
|
|
pathIndex = pathContentIndex;
|
|
|
|
|
GWT.log("showing pathContentIndex: "+pathContentIndex);
|
|
|
|
|
GWT.log("showing ws content: "+listWSC);
|
|
|
|
|
|
|
|
|
|
// map for current content uploading
|
|
|
|
|
mapForCCUploading = new HashMap<Integer, WorkspaceContentDV>(listWSC.size());
|
|
|
|
@ -424,6 +476,12 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
uploadFileContainer.add(table);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showNewFileUpload();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void showNewFileUpload() {
|
|
|
|
|
|
|
|
|
|
HTML label = new HTML();
|
|
|
|
|
label.getElement().getStyle().setMarginTop(10, Unit.PX);
|
|
|
|
|
label.getElement().getStyle().setMarginBottom(10, Unit.PX);
|
|
|
|
|