|
|
|
@ -6,18 +6,24 @@ 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;
|
|
|
|
|
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.RECORD_TYPE;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
|
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.MultipleDilaogUpload;
|
|
|
|
|
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Controls;
|
|
|
|
|
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.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.uibinder.client.UiBinder;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
|
|
|
import com.google.gwt.user.client.Window;
|
|
|
|
@ -36,6 +42,8 @@ import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
*/
|
|
|
|
|
public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
private static final String UPLOAD_MISSING_FILE = "You must upload a file";
|
|
|
|
|
|
|
|
|
|
private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -52,14 +60,17 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
ListBox listBoxPaths;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
ListBox listBoxIndex;
|
|
|
|
|
ControlGroup cgSelectFile;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
ControlGroup cgSelectFile;
|
|
|
|
|
Controls controlsContent;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTMLPanel uploadFileContainer;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
Button buttonUpdate;
|
|
|
|
|
|
|
|
|
|
private List<String> listFileSetPaths;
|
|
|
|
|
|
|
|
|
|
private boolean placeholderRemoved = false;
|
|
|
|
@ -72,6 +83,10 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
|
|
|
|
|
private RECORD_TYPE recordType;
|
|
|
|
|
|
|
|
|
|
private MultipleDilaogUpload mDU;
|
|
|
|
|
|
|
|
|
|
private ChangeHandler listBoxIndexHandler;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Instantiates a new update fileset.
|
|
|
|
|
*
|
|
|
|
@ -118,6 +133,22 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
buttonUpdate.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
@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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -125,68 +156,140 @@ public class UpdateFileset extends Composite {
|
|
|
|
|
*/
|
|
|
|
|
private void showUploadFileGUI() {
|
|
|
|
|
uploadFileContainer.setVisible(true);
|
|
|
|
|
buttonUpdate.setVisible(false);
|
|
|
|
|
uploadFileContainer.clear();
|
|
|
|
|
controlsContent.clear();
|
|
|
|
|
|
|
|
|
|
listBoxIndex.clear();
|
|
|
|
|
// listBoxIndex.clear();
|
|
|
|
|
cgSelectFile.setVisible(true);
|
|
|
|
|
|
|
|
|
|
ListBox listBoxIndex = new ListBox();
|
|
|
|
|
listBoxIndex.setWidth("550px");
|
|
|
|
|
listBoxIndex.addItem("Select a content...");
|
|
|
|
|
|
|
|
|
|
if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) {
|
|
|
|
|
AbstractRelazioneScavoDV ar = fullConcessione.getAbstractRelazioneScavo();
|
|
|
|
|
if (ar == null) {
|
|
|
|
|
showMessage("abstract_relazione " + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
showMessage("abstract_relazione" + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
fillListBoxToBeReplaced("abstract_relazione", ar.getListWsContent());
|
|
|
|
|
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
fillListBoxToBeReplaced(listBoxIndex, "abstract_relazione", posizIndex, ar.getTitolo(),
|
|
|
|
|
ar.getListWsContent());
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains("immagini")) {
|
|
|
|
|
List<UploadedImageDV> listImmagini = fullConcessione.getImmaginiRappresentative();
|
|
|
|
|
if (listImmagini == null || listImmagini.isEmpty()) {
|
|
|
|
|
showMessage("immagini " + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
showMessage("immagini" + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
for (UploadedImageDV uploadedImageDV : listImmagini) {
|
|
|
|
|
fillListBoxToBeReplaced("immagini", uploadedImageDV.getListWsContent());
|
|
|
|
|
fillListBoxToBeReplaced(listBoxIndex, "immagini", 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);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
fillListBoxToBeReplaced(listBoxIndex, "relazione", posizIndex, realzione.getTitolo(),
|
|
|
|
|
realzione.getListWsContent());
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains("posizionamentoScavo")) {
|
|
|
|
|
LayerConcessioneDV posiz = fullConcessione.getPosizionamentoScavo();
|
|
|
|
|
if (posiz == null || posiz.getListWsContent() == null || posiz.getListWsContent().isEmpty()) {
|
|
|
|
|
showMessage("posizionamentoScavo" + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
fillListBoxToBeReplaced(listBoxIndex, "posizionamentoScavo", posizIndex, posiz.getTitolo(),
|
|
|
|
|
posiz.getListWsContent());
|
|
|
|
|
|
|
|
|
|
} else if (listBoxPaths.getSelectedItemText().contains("piante")) {
|
|
|
|
|
List<LayerConcessioneDV> piante = fullConcessione.getPianteFineScavo();
|
|
|
|
|
if (piante == null || piante.isEmpty()) {
|
|
|
|
|
showMessage("piante" + " NOT AVAILABLE", LabelType.WARNING);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int posizIndex = 0;
|
|
|
|
|
for (LayerConcessioneDV lcDV : piante) {
|
|
|
|
|
fillListBoxToBeReplaced(listBoxIndex, "piante", posizIndex, lcDV.getTitolo(), lcDV.getListWsContent());
|
|
|
|
|
posizIndex++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (listBoxIndex.getItemCount() > 1) {
|
|
|
|
|
listBoxIndex.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
controlsContent.add(listBoxIndex);
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onChange(ChangeEvent event) {
|
|
|
|
|
showFileUploadInteraction();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// if (listBoxIndex.getItemCount() > 1) {
|
|
|
|
|
// listBoxIndex.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onChange(ChangeEvent event) {
|
|
|
|
|
// showFileBrowseInteraction();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillListBoxToBeReplaced(String section, List<WorkspaceContentDV> listWSC) {
|
|
|
|
|
private void fillListBoxToBeReplaced(ListBox listBoxIndex, String section, int posizIndex, String title,
|
|
|
|
|
List<WorkspaceContentDV> listWSC) {
|
|
|
|
|
|
|
|
|
|
listBoxIndex.clear();
|
|
|
|
|
|
|
|
|
|
listBoxIndex.addItem("Select a file...");
|
|
|
|
|
// ListBox listBoxIndex = new ListBox();
|
|
|
|
|
// listBoxIndex.addItem("Select a content...");
|
|
|
|
|
|
|
|
|
|
if (listWSC == null || listWSC.isEmpty()) {
|
|
|
|
|
showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listBoxIndex.addItem(title, posizIndex + "");
|
|
|
|
|
|
|
|
|
|
// adding handler once
|
|
|
|
|
if (posizIndex == 0) {
|
|
|
|
|
listBoxIndex.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onChange(ChangeEvent event) {
|
|
|
|
|
showFileBrowseInteraction();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// controlsContent.add(listBoxIndex);
|
|
|
|
|
|
|
|
|
|
for (WorkspaceContentDV wsContent : listWSC) {
|
|
|
|
|
String name = wsContent.getName() == null || wsContent.getName().isEmpty() ? wsContent.getLink()
|
|
|
|
|
: wsContent.getName();
|
|
|
|
|
listBoxIndex.addItem(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showFileUploadInteraction() {
|
|
|
|
|
private void showFileBrowseInteraction() {
|
|
|
|
|
uploadFileContainer.clear();
|
|
|
|
|
HTML label = new HTML();
|
|
|
|
|
label.setHTML("<i>Going to replace the file into section: " + listBoxIndex.getSelectedItemText() + " with</i>");
|
|
|
|
|
label.setHTML("With new one:");
|
|
|
|
|
|
|
|
|
|
uploadFileContainer.add(label);
|
|
|
|
|
MultipleDilaogUpload holder = new MultipleDilaogUpload();
|
|
|
|
|
uploadFileContainer.add(holder);
|
|
|
|
|
mDU = new MultipleDilaogUpload();
|
|
|
|
|
uploadFileContainer.add(mDU);
|
|
|
|
|
buttonUpdate.setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean checkValidUpload() {
|
|
|
|
|
GWT.log("Checking is valid File");
|
|
|
|
|
|
|
|
|
|
if (mDU.getFileUploadingState() != null && mDU.getFileUploadingState().getFile() != null) {
|
|
|
|
|
return mDU.getFileUploadingState().getFile().getTempSystemPath() != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showMessage(String txt, LabelType type) {
|
|
|
|
|