diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java index fc43957..878b145 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java @@ -1,7 +1,5 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; -import java.util.List; - import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; @@ -26,6 +24,7 @@ import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.Widget; /** @@ -41,12 +40,15 @@ public class EditModeRecord extends Composite { @UiField Tab tabRawUpdate; + + @UiField + Tab tabUploadFiles; @UiField FlowPanel rawUpdatePanel; @UiField - FlowPanel filesUpdatePanel; + ScrollPanel filesUpdatePanel; @UiField Button buttonJSONUpdate; @@ -81,6 +83,8 @@ public class EditModeRecord extends Composite { this.selectedConcessione = selectedConcessione; this.recordType = type; this.appManagerBus = appManagerBus; + this.filesUpdatePanel.setHeight("490px"); + //filesUpdatePanel.getElement().getStyle().setProperty("maxHeight", "550px"); instanceJSONEditor(); instanceUpdateFilesetEditor(); @@ -99,6 +103,7 @@ public class EditModeRecord extends Composite { @Override public void onSuccess(FileSetPathsDV fileSetPaths) { UpdateFileset updateFileset = new UpdateFileset(selectedConcessione, recordType, fileSetPaths.getFileSetPaths()); + //updateFileset.setHeight("300px !important"); filesUpdatePanel.add(updateFileset); } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml index a8bea29..fdeac36 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml @@ -24,7 +24,8 @@ Source Project Editor - You can update the Source Project by editing its model + You can update the Source Project by editing + its model data displayed in the following Editor.

@@ -41,7 +42,8 @@ del progetto") reported in green by the - Editor
+ Editor +
At the end of the changes press the "Update" button to make them persistent on the service

@@ -49,15 +51,23 @@ UPDATE + addStyleNames="{style.button-save-style}" + ui:field="buttonJSONUpdate">UPDATE
Update the file/s By choosing a section (e.g. "relazione") and uploading new file/s the old one/s will be replaced - - + +

+ At the end of the changes press the "Update" button to + make + them persistent on the service +

+
+ +
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java index a281a56..d6c73a6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java @@ -11,7 +11,10 @@ import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScav 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 org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField; +import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton; +import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper; +import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.ControlGroup; @@ -20,15 +23,18 @@ 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.dom.client.Style.Unit; 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.event.shared.HandlerManager; 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; +import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Widget; @@ -42,7 +48,7 @@ import com.google.gwt.user.client.ui.Widget; */ public class UpdateFileset extends Composite { - private static final String _700PX = "700px"; + private static final String _FORM_FIELDS_SIZE = "740px"; private static final String UPLOAD_MISSING_FILE = "You must upload a file"; @@ -75,7 +81,7 @@ public class UpdateFileset extends Composite { private List listFileSetPaths; - private boolean placeholderRemoved = false; + private boolean listBoxPathsPlaceholder = true; private String recordId; @@ -85,9 +91,13 @@ public class UpdateFileset extends Composite { private RECORD_TYPE recordType; - private MultipleDilaogUpload mDU; + // private MultipleDilaogUpload mDU; - private ChangeHandler listBoxIndexHandler; + private boolean listBoxIndexPlaceholder = true; + + private HandlerManager uiBus = new HandlerManager(null); + + private MetaDataField fieldUploadWidget; /** * Instantiates a new update fileset. @@ -103,7 +113,7 @@ public class UpdateFileset extends Composite { for (String path : listFileSetPaths) { listBoxPaths.addItem(path); } - listBoxPaths.setWidth(_700PX); + listBoxPaths.setWidth(_FORM_FIELDS_SIZE); // add handler on select listBoxPaths.addChangeHandler(new ChangeHandler() { @@ -113,9 +123,9 @@ public class UpdateFileset extends Composite { GWT.log("Profile type selection changed..."); cgSelectFile.setVisible(false); - if (!placeholderRemoved) { - listBoxPaths.removeItem(0); // this is the placeholder - placeholderRemoved = true; + if (listBoxPathsPlaceholder) { + listBoxPaths.removeItem(0); // this is the placeholder, removing it once + listBoxPathsPlaceholder = false; } showUploadFileGUI(); } @@ -141,12 +151,10 @@ public class UpdateFileset extends Composite { @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); - } + if (checkValidUpload() == null) { + Window.alert("I can save..."); + } else { + Window.alert("New file not found. " + UPLOAD_MISSING_FILE); } } @@ -162,12 +170,14 @@ public class UpdateFileset extends Composite { buttonUpdate.setVisible(false); uploadFileContainer.clear(); controlsContent.clear(); + listBoxIndexPlaceholder = true; + fieldUploadWidget = null; // listBoxIndex.clear(); cgSelectFile.setVisible(true); ListBox listBoxIndex = new ListBox(); - listBoxIndex.setWidth(_700PX); + listBoxIndex.setWidth(_FORM_FIELDS_SIZE); listBoxIndex.addItem("Select a content..."); if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) { @@ -230,24 +240,11 @@ public class UpdateFileset extends Composite { controlsContent.add(listBoxIndex); -// if (listBoxIndex.getItemCount() > 1) { -// listBoxIndex.addChangeHandler(new ChangeHandler() { -// -// @Override -// public void onChange(ChangeEvent event) { -// showFileBrowseInteraction(); -// } -// }); -// } - } private void fillListBoxToBeReplaced(ListBox listBoxIndex, String section, int posizIndex, String title, List listWSC) { -// ListBox listBoxIndex = new ListBox(); -// listBoxIndex.addItem("Select a content..."); - if (listWSC == null || listWSC.isEmpty()) { showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING); return; @@ -257,42 +254,92 @@ public class UpdateFileset extends Composite { // adding handler once if (posizIndex == 0) { + listBoxIndex.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { - showFileBrowseInteraction(); + + if (listBoxIndexPlaceholder) { + listBoxIndex.removeItem(0); // this is the placeholder, removing it once + listBoxIndexPlaceholder = false; + } + + showFileBrowseInteraction(listWSC); } }); } // -// controlsContent.add(listBoxIndex); - for (WorkspaceContentDV wsContent : listWSC) { - String name = wsContent.getName() == null || wsContent.getName().isEmpty() ? wsContent.getLink() - : wsContent.getName(); - } } - private void showFileBrowseInteraction() { + private void showFileBrowseInteraction(List listWSC) { uploadFileContainer.clear(); - HTML label = new HTML(); - label.setHTML("With new one:"); - uploadFileContainer.add(label); - mDU = new MultipleDilaogUpload(); - uploadFileContainer.add(mDU); - buttonUpdate.setVisible(true); - } + if (listWSC.size() > 0) { + FlexTable table = new FlexTable(); + table.addStyleName("table-current-content"); + table.setHTML(0, 0, "Current content:"); + table.setHTML(1, 0, "Filename"); + table.setHTML(1, 1, "MimeType"); + table.setHTML(1, 2, "Link"); + int i = 2; + for (WorkspaceContentDV wsContent : listWSC) { + table.setHTML(i, 0, wsContent.getName()); + table.setHTML(i, 1, wsContent.getMimetype()); + String link = "Download"; + table.setHTML(i, 2, link); + i++; + } - private boolean checkValidUpload() { - GWT.log("Checking is valid File"); - - if (mDU.getFileUploadingState() != null && mDU.getFileUploadingState().getFile() != null) { - return mDU.getFileUploadingState().getFile().getTempSystemPath() != null; + uploadFileContainer.add(table); } - return false; + HTML label = new HTML(); + label.getElement().getStyle().setMarginTop(10, Unit.PX); + label.setHTML("With new content:"); + uploadFileContainer.add(label); + // mDU = new MultipleDilaogUpload(); + + MetadataFieldWrapper uploadField = new MetadataFieldWrapper(); + uploadField.setFieldName("File"); + uploadField.setMandatory(true); + uploadField.setType(DataTypeWrapper.File); + uploadField.setMaxOccurs(1000); + + try { + fieldUploadWidget = new MetaDataField(uploadField, uiBus); + //BrowseFilePanel fieldsetContent = new BrowseFilePanel(fieldUploadWidget); + uploadFileContainer.add(fieldUploadWidget); + + buttonUpdate.setVisible(true); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * Test if profile data are valid. + * + * @return the string + */ + private String checkValidUpload() { + + 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; + } + } + + return null; } private void showMessage(String txt, LabelType type) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml index b60810d..ac27ab0 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml @@ -14,7 +14,7 @@ - + Section @@ -30,7 +30,9 @@ - + + + diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index 0a9a0ce..e5e8797 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -94,8 +94,17 @@ h1 { pointer-events: none; } -.form-fielset-edit { +.form-fieldset-edit { margin: 10px 0px !important; border: 1px groove #ddd !important; padding: 10px !important; } + +.table-current-content { + width: 100%; + background-color: #efefef; +} + +.table-current-content td { + padding: 5px; +}