Edit FileSet on-going

This commit is contained in:
Francesco Mangiacrapa 2021-09-28 17:31:16 +02:00
parent 541c190820
commit 282ad3980d
3 changed files with 159 additions and 33 deletions

View File

@ -24,7 +24,7 @@
<b:Tab icon="PENCIL" active="true" heading="Edit the source"
ui:field="tabRawUpdate">
<b:Heading size="3">Source Project Editor</b:Heading>
<b:Label type="INFO">You can update the Source Project by editing its JSON model
<b:Label type="INFO">You can update the Source Project by editing its model
data displayed in the following Editor.</b:Label>
<g:HTML addStyleNames="{style.info-panel}">
<p style='color: #585858'>

View File

@ -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);
/**
@ -51,15 +59,18 @@ public class UpdateFileset extends Composite {
@UiField
ListBox listBoxPaths;
@UiField
ListBox listBoxIndex;
@UiField
ControlGroup cgSelectFile;
@UiField
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) {

View File

@ -6,24 +6,47 @@
.important {
font-weight: bold;
}
.button-save-style {
margin-top: 10px;
float: right;
}
.width-550 {
width: 550px;
}
.form-fielset {
margin: 10px 0px;
border: 1px groove #ddd;
padding: 10px;
}
</ui:style>
<g:HTMLPanel>
<b:Form type="INLINE">
<b:Fieldset>
<b:Fieldset addStyleNames="{style.form-fielset}">
<b:ControlGroup>
<b:ControlLabel>Section</b:ControlLabel>
<b:Controls>
<b:ListBox ui:field="listBoxPaths"></b:ListBox>
<b:ListBox ui:field="listBoxPaths"
addStyleNames="{style.width-550}"></b:ListBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cgSelectFile" visible="false">
<b:ControlLabel>Select File to be replaced</b:ControlLabel>
<b:Controls>
<b:ListBox ui:field="listBoxIndex"></b:ListBox>
<b:ControlGroup ui:field="cgSelectFile"
visible="false">
<b:ControlLabel>Replace the content</b:ControlLabel>
<b:Controls ui:field="controlsContent">
<!-- <b:ListBox ui:field="listBoxIndex" -->
<!-- addStyleNames="{style.width-500}"></b:ListBox> -->
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<g:HTMLPanel ui:field="uploadFileContainer"></g:HTMLPanel>
</b:ControlGroup>
</b:Fieldset>
</b:Form>
<g:HTMLPanel ui:field="uploadFileContainer"></g:HTMLPanel>
<b:Button icon="SAVE" type="INFO"
addStyleNames="{style.button-save-style}" ui:field="buttonUpdate"
visible="false">UPDATE</b:Button>
</g:HTMLPanel>
</ui:UiBinder>