Added fields description as tooltip

This commit is contained in:
Francesco Mangiacrapa 2020-01-17 12:46:32 +01:00
parent 6d5de0712a
commit 95ea2396e9
16 changed files with 248 additions and 300 deletions

View File

@ -1,6 +1,8 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client; package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.Ckan2ZenodoViewManager; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.Ckan2ZenodoViewManager;
@ -35,6 +37,7 @@ public class CkanToZendoPublisherWidget {
private Ckan2ZenodoViewManager manager = null; private Ckan2ZenodoViewManager manager = null;
private BasicTabPanel basicTabPanel; private BasicTabPanel basicTabPanel;
private ModalFooter modalFooter; private ModalFooter modalFooter;
public static Map<String, String> mapOfFieldsDescriptions = new HashMap<String, String>();
public CkanToZendoPublisherWidget() { public CkanToZendoPublisherWidget() {
@ -85,6 +88,20 @@ public class CkanToZendoPublisherWidget {
} }
}); });
ckanToZenodoService.readFieldsDescriptions(new AsyncCallback<Map<String,String>>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(Map<String, String> result) {
mapOfFieldsDescriptions = result;
}
});
buttonPublish.addClickHandler(new ClickHandler() { buttonPublish.addClickHandler(new ClickHandler() {
@Override @Override

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client; package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
import java.util.Map;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
@ -16,4 +18,6 @@ public interface CkanToZenodoPublisherService extends RemoteService {
String publishOnZenodo(ZenodoItem zenodoItem) throws Exception; String publishOnZenodo(ZenodoItem zenodoItem) throws Exception;
Map<String, String> readFieldsDescriptions() throws Exception;
} }

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client; package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
import java.util.Map;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
@ -32,6 +34,8 @@ public interface CkanToZenodoPublisherServiceAsync {
void convertToZenodoItem(CatalogueItem item, AsyncCallback<ZenodoItem> callback); void convertToZenodoItem(CatalogueItem item, AsyncCallback<ZenodoItem> callback);
void publishOnZenodo(ZenodoItem zenodoItem, AsyncCallback<String> callback); void publishOnZenodo(ZenodoItem zenodoItem, AsyncCallback<String> callback);
void readFieldsDescriptions(AsyncCallback<Map<String, String>> callback);
} }

View File

@ -10,7 +10,6 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuth
import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.ControlLabel; import com.github.gwtbootstrap.client.ui.ControlLabel;
import com.github.gwtbootstrap.client.ui.Controls;
import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.TextBox; import com.github.gwtbootstrap.client.ui.TextBox;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
@ -22,7 +21,6 @@ import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
@ -109,6 +107,14 @@ public class CreatorView extends Composite {
} }
} }
if(userRole.toLowerCase().startsWith("creator")) {
InfoTextAndLabels.addFieldDescriptionInfo("creators", field_cl_author);
}else if(userRole.toLowerCase().startsWith("contributor")) {
InfoTextAndLabels.addFieldDescriptionInfo("contributors", field_cl_author);
}else {
InfoTextAndLabels.addFieldDescriptionInfo("authors", field_cl_author);
}
GWT.log("Created creator view with author: "+this.author); GWT.log("Created creator view with author: "+this.author);
} }

View File

@ -2,12 +2,11 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformati
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors.CreatorsFormView; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors.CreatorsFormView;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.tags.TagsPanel; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.tags.TagsPanel;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils.FieldDescription; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils.InfoTextAndLabels;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FieldUtil; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FieldUtil;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor;
@ -18,6 +17,7 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoMeta
import com.github.gwtbootstrap.client.ui.Alert; import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.ControlLabel;
import com.github.gwtbootstrap.client.ui.Fieldset; import com.github.gwtbootstrap.client.ui.Fieldset;
import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.TextArea; import com.github.gwtbootstrap.client.ui.TextArea;
@ -54,6 +54,9 @@ public class BasicInformationView extends Composite implements FormValidator {
@UiField @UiField
TextBox field_title; TextBox field_title;
@UiField
ControlLabel cl_title;
@UiField @UiField
TextBox field_doi; TextBox field_doi;
@ -63,24 +66,42 @@ public class BasicInformationView extends Composite implements FormValidator {
@UiField @UiField
TextArea field_description; TextArea field_description;
@UiField
ControlLabel cl_description;
@UiField @UiField
ListBox field_upload_type; ListBox field_upload_type;
@UiField
ControlLabel cl_upload_type;
@UiField @UiField
ListBox field_access_right; ListBox field_access_right;
@UiField
ControlLabel cl_access_right;
@UiField @UiField
ListBox field_license; ListBox field_license;
@UiField
ControlLabel cl_license;
@UiField @UiField
ListBox field_publication_type; ListBox field_publication_type;
@UiField
ControlLabel cl_publication_type;
@UiField @UiField
DateBox field_publication_date; DateBox field_publication_date;
@UiField
ControlLabel cl_publication_date;
@UiField @UiField
Alert error_alert; Alert error_alert;
@UiField @UiField
TagsPanel the_tags_panel; TagsPanel the_tags_panel;
@ -93,8 +114,6 @@ public class BasicInformationView extends Composite implements FormValidator {
private ZenodoItem zenodoItem; private ZenodoItem zenodoItem;
/** /**
* Because this class has a default constructor, it can be used as a binder * Because this class has a default constructor, it can be used as a binder
* template. In other words, it can be used in other *.ui.xml files as follows: * template. In other words, it can be used in other *.ui.xml files as follows:
@ -155,8 +174,6 @@ public class BasicInformationView extends Composite implements FormValidator {
} }
} }
} }
/** /**
* Fill parameters to operator. * Fill parameters to operator.
@ -164,188 +181,80 @@ public class BasicInformationView extends Composite implements FormValidator {
private void fillForm() { private void fillForm() {
field_title.setValue(zenodoItem.getTitle()); field_title.setValue(zenodoItem.getTitle());
InfoTextAndLabels.addFieldDescriptionInfo("title", cl_title);
field_description.setValue(zenodoItem.getMetadata().getDescription()); field_description.setValue(zenodoItem.getMetadata().getDescription());
InfoTextAndLabels.addFieldDescriptionInfo("description", cl_description);
field_doi.setValue(zenodoItem.getDoi().toString()); field_doi.setValue(zenodoItem.getDoi().toString());
ZenodoMetadata zMeta = zenodoItem.getMetadata(); ZenodoMetadata zMeta = zenodoItem.getMetadata();
if (zMeta != null) { if (zMeta != null) {
String title = zenodoItem.getTitle()!=null?zenodoItem.getTitle():zMeta.getTitle(); String title = zenodoItem.getTitle() != null ? zenodoItem.getTitle() : zMeta.getTitle();
field_title.setValue(title); // Re.fill title to be sure
String value = zenodoItem.getFieldsDescriptions().get("title");
if(value!=null) { // Upload type
Widget parent = field_title.getParent(); if (zMeta.getUpload_type() != null) {
FieldDescription fd = new FieldDescription(null, value);
parent.getElement().appendChild(fd.getElement());
}
field_title.setValue(title); //Re.fill title to be sure
//Upload type
if(zMeta.getUpload_type()!=null) {
FieldUtil.addValuesToListBox(field_upload_type, zMeta.getUpload_type().getSelectableValues()); FieldUtil.addValuesToListBox(field_upload_type, zMeta.getUpload_type().getSelectableValues());
FieldUtil.selectValueToListBox(field_upload_type, zMeta.getUpload_type().getSelectedValues()); FieldUtil.selectValueToListBox(field_upload_type, zMeta.getUpload_type().getSelectedValues());
}else } else
field_upload_type.setEnabled(false); field_upload_type.setEnabled(false);
//Publication Type InfoTextAndLabels.addFieldDescriptionInfo("upload_type", cl_upload_type);
if(zMeta.getPublication_type()!=null) {
// Publication Type
if (zMeta.getPublication_type() != null) {
FieldUtil.addValuesToListBox(field_publication_type, zMeta.getPublication_type().getSelectableValues()); FieldUtil.addValuesToListBox(field_publication_type, zMeta.getPublication_type().getSelectableValues());
FieldUtil.selectValueToListBox(field_publication_type, zMeta.getPublication_type().getSelectedValues()); FieldUtil.selectValueToListBox(field_publication_type, zMeta.getPublication_type().getSelectedValues());
}else } else
field_publication_type.setEnabled(false); field_publication_type.setEnabled(false);
if(zMeta.getAccess_right()!=null) { InfoTextAndLabels.addFieldDescriptionInfo("publication_type", cl_publication_type);
if (zMeta.getAccess_right() != null) {
FieldUtil.addValuesToListBox(field_access_right, zMeta.getAccess_right().getSelectableValues()); FieldUtil.addValuesToListBox(field_access_right, zMeta.getAccess_right().getSelectableValues());
FieldUtil.selectValueToListBox(field_access_right, zMeta.getAccess_right().getSelectedValues()); FieldUtil.selectValueToListBox(field_access_right, zMeta.getAccess_right().getSelectedValues());
}else } else
field_access_right.setEnabled(false); field_access_right.setEnabled(false);
if(zMeta.getLicense()!=null) { InfoTextAndLabels.addFieldDescriptionInfo("access_right", cl_access_right);
if (zMeta.getLicense() != null) {
FieldUtil.addValuesToListBox(field_license, Arrays.asList(zMeta.getLicense().getId())); FieldUtil.addValuesToListBox(field_license, Arrays.asList(zMeta.getLicense().getId()));
FieldUtil.selectValueToListBox(field_license, Arrays.asList(zMeta.getLicense().getId())); FieldUtil.selectValueToListBox(field_license, Arrays.asList(zMeta.getLicense().getId()));
} }
field_license.setEnabled(false); //because is not changeable field_license.setEnabled(false); // because is not changeable
if(zMeta.getKeywords()!=null && zMeta.getKeywords().size()>0) { InfoTextAndLabels.addFieldDescriptionInfo("license", cl_license);
if (zMeta.getKeywords() != null && zMeta.getKeywords().size() > 0) {
for (String keyword : zMeta.getKeywords()) { for (String keyword : zMeta.getKeywords()) {
the_tags_panel.addTagElement(keyword); the_tags_panel.addTagElement(keyword);
} }
} }
if(listOfCreatorsView==null) if (listOfCreatorsView == null)
listOfCreatorsView = new ArrayList<CreatorsFormView>(); listOfCreatorsView = new ArrayList<CreatorsFormView>();
if(listOfContributorsView==null) if (listOfContributorsView == null)
listOfContributorsView = new ArrayList<CreatorsFormView>(); listOfContributorsView = new ArrayList<CreatorsFormView>();
// ADDING AUTHORS // ADDING AUTHORS
GWT.log("Adding creators: "+zenodoItem.getMetadata().getCreators()); GWT.log("Adding creators: " + zenodoItem.getMetadata().getCreators());
CreatorsFormView authorView = new CreatorsFormView(zenodoItem.getMetadata().getCreators()); CreatorsFormView authorView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
listOfCreatorsView.add(authorView); listOfCreatorsView.add(authorView);
GWT.log("Adding contributors: "+zenodoItem.getMetadata().getContributors()); GWT.log("Adding contributors: " + zenodoItem.getMetadata().getContributors());
CreatorsFormView contributorView = new CreatorsFormView(zenodoItem.getMetadata().getContributors()); CreatorsFormView contributorView = new CreatorsFormView(zenodoItem.getMetadata().getContributors());
listOfContributorsView.add(contributorView); listOfContributorsView.add(contributorView);
for (CreatorsFormView cfv : listOfCreatorsView) { for (CreatorsFormView cfv : listOfCreatorsView) {
fieldset_basic_informations.add(cfv); fieldset_basic_informations.add(cfv);
} }
for (CreatorsFormView cfv : listOfContributorsView) { for (CreatorsFormView cfv : listOfContributorsView) {
fieldset_basic_informations.add(cfv); fieldset_basic_informations.add(cfv);
} }
} }
// if(zenodoItem.getFiles()!=null) {
// label_files.setVisible(true);
// for (ZenodoFile file : zenodoItem.getFiles()) {
// addFileForPublishing(file);
// }
// }
}
// /**
// * Adds the values to list box.
// *
// * @param list the list
// * @param listValues the list values
// */
// private void addValuesToListBox(ListBox list, List<String> listValues) {
// if (listValues == null)
// return;
//
// for (int i = 0; i < listValues.size(); i++) {
// list.addItem(listValues.get(i), listValues.get(i));
// }
// }
//
// /**
// * Select value to list box.
// *
// * @param list the list
// * @param values the values
// */
// private void selectValueToListBox(ListBox list, List<String> values) {
// GWT.log("Selecting value: "+values);
// String selectValue = null;
// if (values == null || values.isEmpty()) {
// selectValue = null;
// } else {
// selectValue = values.get(0);
// }
//
// try {
// if (list.getItemCount() > 0)
// list.setSelectedValue(selectValue);
// } catch (Exception e) {
// GWT.log("error: " + e);
// }
// }
// private void addFileForPublishing(ZenodoFile file) {
// PublishFileView pv = new PublishFileView();
// pv.getField_file_name().setValue(file.getFilename());
// pv.getSwitchButton().setValue(true);
// to_zenodo_form_unit_fields.add(pv);
// }
// /**
// * Bind events.
// */
// private void bindEvents() {
//
// pager.getLeft().addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
//
// }
// });
//
// pager.getRight().addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
// setError(false, "");
// boolean isValid = validateSubmit();
// if (isValid)
// submitHandler();
//
// }
// });
// }
/**
* Validate submit.
*
* @return true, if successful
*/
protected boolean validateSubmit() {
/*
* cg_select_task_id.setType(ControlGroupType.NONE);
* //cg_parameters_control.setType(ControlGroupType.NONE);
* //cg_remote_path.setType(ControlGroupType.NONE);
*
* if(field_select_scope.getSelectedItemText()==null){
* cg_select_vre.setType(ControlGroupType.ERROR); setError(true,
* "You must select a Scope!"); return false; }
*
* if(field_select_scope.getSelectedItemText() == null ||
* field_select_scope.getSelectedItemText().isEmpty()){
* cg_select_task_id.setType(ControlGroupType.ERROR); setError(true,
* "You must select an Algorithm!"); return false; }
*
* for (CustomFieldEntry cFE : customFieldEntriesList) {
* cFE.getControlGroup().setType(ControlGroupType.NONE); if(cFE.getKey()==null
* || cFE.getKey().isEmpty()){
* cFE.getControlGroup().setType(ControlGroupType.ERROR);
* //cg_parameters_control.setType(ControlGroupType.ERROR); setError(true,
* "You must type a valid key parameter!"); return false; } }
*/
return true;
} }
/** /**
@ -367,73 +276,75 @@ public class BasicInformationView extends Composite implements FormValidator {
*/ */
@Override @Override
public String validateFormFields() { public String validateFormFields() {
error_alert.setVisible(false); error_alert.setVisible(false);
ControlGroup cgDOI = FieldUtil.getParentControlGroupOfWidget(field_doi); ControlGroup cgDOI = FieldUtil.getParentControlGroupOfWidget(field_doi);
ControlGroup cgTitle = FieldUtil.getParentControlGroupOfWidget(field_title); ControlGroup cgTitle = FieldUtil.getParentControlGroupOfWidget(field_title);
FieldUtil.setControlGroup(cgDOI, ControlGroupType.NONE); FieldUtil.setControlGroup(cgDOI, ControlGroupType.NONE);
FieldUtil.setControlGroup(cgTitle, ControlGroupType.NONE); FieldUtil.setControlGroup(cgTitle, ControlGroupType.NONE);
//Validating DOI // Validating DOI
if (cgDOI.isVisible()) { if (cgDOI.isVisible()) {
GWT.log("Checking doi---"); GWT.log("Checking doi---");
String value = getTextValue(field_doi); String value = getTextValue(field_doi);
boolean isValid = FieldUtil.isValidValue(value); boolean isValid = FieldUtil.isValidValue(value);
if(!isValid) { if (!isValid) {
FieldUtil.setControlGroup(cgDOI, ControlGroupType.ERROR); FieldUtil.setControlGroup(cgDOI, ControlGroupType.ERROR);
error_alert.setVisible(true); error_alert.setVisible(true);
error_alert.setText("This field DOI is required"); error_alert.setText("This field DOI is required");
return "This field is required"; return "This field is required";
} }
} }
//Validating Title // Validating Title
if (cgTitle.isVisible()) { if (cgTitle.isVisible()) {
GWT.log("Checking title---"); GWT.log("Checking title---");
String value = getTextValue(field_title); String value = getTextValue(field_title);
boolean isValid = FieldUtil.isValidValue(value); boolean isValid = FieldUtil.isValidValue(value);
GWT.log("isValid: "+isValid); GWT.log("isValid: " + isValid);
if(!isValid) { if (!isValid) {
FieldUtil.setControlGroup(cgTitle, ControlGroupType.ERROR); FieldUtil.setControlGroup(cgTitle, ControlGroupType.ERROR);
error_alert.setVisible(true); error_alert.setVisible(true);
error_alert.setText("The field Title is required"); error_alert.setText("The field Title is required");
return "This field is required"; return "This field is required";
} }
} }
//Validating Creators // Validating Creators
for (CreatorsFormView cfv : listOfCreatorsView) { for (CreatorsFormView cfv : listOfCreatorsView) {
String error = cfv.validateFormFields(); String error = cfv.validateFormFields();
if(error!=null) { if (error != null) {
error_alert.setVisible(true); error_alert.setVisible(true);
error_alert.setText(error); error_alert.setText(error);
return error; return error;
} }
} }
//Validating Contributors // Validating Contributors
for (CreatorsFormView cfv : listOfContributorsView) { for (CreatorsFormView cfv : listOfContributorsView) {
String error = cfv.validateFormFields(); String error = cfv.validateFormFields();
if(error!=null) { if (error != null) {
error_alert.setVisible(true); error_alert.setVisible(true);
error_alert.setText(error); error_alert.setText(error);
return error; return error;
} }
} }
return null; return null;
} }
/* (non-Javadoc) /*
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator#isValidForm() * (non-Javadoc)
*
* @see
* org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator#
* isValidForm()
*/ */
@Override @Override
public boolean isValidForm() { public boolean isValidForm() {
return validateFormFields()==null; return validateFormFields() == null;
} }
/** /**
* Gets the text value. * Gets the text value.
@ -454,7 +365,7 @@ public class BasicInformationView extends Composite implements FormValidator {
public List<CreatorsFormView> getListOfContributorsView() { public List<CreatorsFormView> getListOfContributorsView() {
return listOfContributorsView; return listOfContributorsView;
} }
/** /**
* Gets the list of creators view. * Gets the list of creators view.
* *
@ -463,7 +374,7 @@ public class BasicInformationView extends Composite implements FormValidator {
public List<CreatorsFormView> getListOfCreatorsView() { public List<CreatorsFormView> getListOfCreatorsView() {
return listOfCreatorsView; return listOfCreatorsView;
} }
/** /**
* Gets the list of authors. * Gets the list of authors.
* *
@ -479,8 +390,7 @@ public class BasicInformationView extends Composite implements FormValidator {
} }
return listOfCreators; return listOfCreators;
} }
/** /**
* Gets the list of contributors. * Gets the list of contributors.
* *
@ -586,7 +496,7 @@ public class BasicInformationView extends Composite implements FormValidator {
public Alert getError_alert() { public Alert getError_alert() {
return error_alert; return error_alert;
} }
/** /**
* Gets the tags. * Gets the tags.
* *
@ -595,17 +505,14 @@ public class BasicInformationView extends Composite implements FormValidator {
public List<String> getTags() { public List<String> getTags() {
return the_tags_panel.getTags(); return the_tags_panel.getTags();
} }
/** /**
* Gets the list of keywords. * Gets the list of keywords.
* *
* @return the list of keywords * @return the list of keywords
*/ */
public List<String> getListOfKeywords(){ public List<String> getListOfKeywords() {
return the_tags_panel.getTags(); return the_tags_panel.getTags();
} }
} }

View File

@ -37,7 +37,7 @@
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup ui:field="cg_title"> <b:ControlGroup ui:field="cg_title">
<b:ControlLabel for="cl_title"> <b:ControlLabel for="cl_title" ui:field="cl_title">
<font color="red">*</font> <font color="red">*</font>
Title Title
</b:ControlLabel> </b:ControlLabel>
@ -50,7 +50,7 @@
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup ui:field="cg_description"> <b:ControlGroup ui:field="cg_description">
<b:ControlLabel for="cl_description"> <b:ControlLabel for="cl_description" ui:field="cl_description">
<font color="red">*</font> <font color="red">*</font>
Description Description
</b:ControlLabel> </b:ControlLabel>
@ -66,7 +66,7 @@
<b:ControlGroup ui:field="cg_upload_type"> <b:ControlGroup ui:field="cg_upload_type">
<b:ControlLabel for="cg_upload_type"> <b:ControlLabel for="cg_upload_type" ui:field="cl_upload_type">
Upload type Upload type
</b:ControlLabel> </b:ControlLabel>
<b:Controls> <b:Controls>
@ -79,7 +79,7 @@
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup ui:field="cg_publication_type"> <b:ControlGroup ui:field="cg_publication_type">
<b:ControlLabel for="cl_publication_type"> <b:ControlLabel for="cl_publication_type" ui:field="cl_publication_type">
Publication type Publication type
</b:ControlLabel> </b:ControlLabel>
<b:Controls> <b:Controls>
@ -92,7 +92,7 @@
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup ui:field="cg_access_right"> <b:ControlGroup ui:field="cg_access_right">
<b:ControlLabel for="cl_access_right"> <b:ControlLabel for="cl_access_right" ui:field="cl_access_right">
Access right Access right
</b:ControlLabel> </b:ControlLabel>
<b:Controls> <b:Controls>
@ -105,7 +105,7 @@
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup ui:field="cg_license"> <b:ControlGroup ui:field="cg_license">
<b:ControlLabel for="cl_license"> <b:ControlLabel for="cl_license" ui:field="cl_license">
License License
</b:ControlLabel> </b:ControlLabel>
<b:Controls> <b:Controls>
@ -117,7 +117,7 @@
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup ui:field="cg_publication_date"> <b:ControlGroup ui:field="cg_publication_date">
<b:ControlLabel for="cl_publication_date"> <b:ControlLabel for="cl_publication_date" ui:field="cl_publication_date">
Publication date Publication date
</b:ControlLabel> </b:ControlLabel>
<b:Controls> <b:Controls>

View File

@ -5,8 +5,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.gcube.portlets.user.gcubewidgets.client.elements.Span; import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils.InfoTextAndLabels;
import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.ControlLabel;
import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.TextBox; import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.base.ListItem; import com.github.gwtbootstrap.client.ui.base.ListItem;
@ -37,11 +39,9 @@ public class TagsPanel extends Composite{
@UiField TextBox tagsEnterTextBox; @UiField TextBox tagsEnterTextBox;
@UiField FlowPanel tagsPanel; @UiField FlowPanel tagsPanel;
// @UiField Icon infoIconTags;
// @UiField FocusPanel focusPanelTags;
// @UiField Popover popoverTags;
@UiField ControlGroup tagsInsertGroup; @UiField ControlGroup tagsInsertGroup;
@UiField ListBox tagsEnterListBox; @UiField ListBox tagsEnterListBox;
@UiField ControlLabel cl_keywords;
// regular expression for tags // regular expression for tags
private static final String REGEX_TAG = "^[a-zA-Z0-9]*$"; private static final String REGEX_TAG = "^[a-zA-Z0-9]*$";
@ -57,6 +57,8 @@ public class TagsPanel extends Composite{
tagsEnterListBox.setVisible(false); tagsEnterListBox.setVisible(false);
tagsList.clear(); tagsList.clear();
tagsPanel.clear(); tagsPanel.clear();
InfoTextAndLabels.addFieldDescriptionInfo("keywords", cl_keywords);
} }
@ -87,22 +89,6 @@ public class TagsPanel extends Composite{
} }
} }
// /**
// * Prepare icons
// * @param popupOpenedIds
// */
// public void prepareIcon(List<String> popupOpenedIds) {
// InfoTextAndLabels.preparePopupPanelAndPopover(
// InfoTextAndLabels.TAGS_INFO_ID_POPUP,
// InfoTextAndLabels.TAGS_INFO_TEXT,
// InfoTextAndLabels.TAGS_INFO_CAPTION,
// infoIconTags,
// popoverTags,
// focusPanelTags,
// popupOpenedIds
// );
// }
@UiHandler("tagsEnterTextBox") @UiHandler("tagsEnterTextBox")
void onAddTag(KeyDownEvent event){ void onAddTag(KeyDownEvent event){

View File

@ -9,7 +9,7 @@
</ui:style> </ui:style>
<g:HTMLPanel> <g:HTMLPanel>
<b:ControlGroup ui:field="tagsInsertGroup"> <b:ControlGroup ui:field="tagsInsertGroup">
<b:ControlLabel for="tags" title="Item tag"> <b:ControlLabel for="tags" title="Item tag" ui:field="cl_keywords">
<!-- <font color="red">*</font> --> <!-- <font color="red">*</font> -->
Keywords Keywords
</b:ControlLabel> </b:ControlLabel>

View File

@ -1,38 +1,38 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils; //package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils;
//
import com.github.gwtbootstrap.client.ui.Icon; //import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.Popover; //import com.github.gwtbootstrap.client.ui.Popover;
import com.google.gwt.core.client.GWT; //import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Cursor; //import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.uibinder.client.UiBinder; //import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; //import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite; //import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML; //import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget; //import com.google.gwt.user.client.ui.Widget;
//
public class FieldDescription extends Composite { //public class FieldDescription extends Composite {
//
private static FieldDescriptionUiBinder uiBinder = GWT.create(FieldDescriptionUiBinder.class); // private static FieldDescriptionUiBinder uiBinder = GWT.create(FieldDescriptionUiBinder.class);
//
interface FieldDescriptionUiBinder extends UiBinder<Widget, FieldDescription> { // interface FieldDescriptionUiBinder extends UiBinder<Widget, FieldDescription> {
} // }
//
@UiField // @UiField
Popover popoverDescription; // Popover popoverDescription;
//
@UiField // @UiField
Icon infoIconDescription; // Icon infoIconDescription;
//
public FieldDescription(String captionText, String text) { // public FieldDescription(String captionText, String text) {
initWidget(uiBinder.createAndBindUi(this)); // initWidget(uiBinder.createAndBindUi(this));
//
// prepare the popover // // prepare the popover
if(captionText!=null) // if(captionText!=null)
popoverDescription.setHeading(new HTML("<b>" + captionText + "</b>").getHTML()); // popoverDescription.setHeading(new HTML("<b>" + captionText + "</b>").getHTML());
//
popoverDescription.setText(new HTML("<p style='color:initial'>" + text + "</p>").getHTML()); // popoverDescription.setText(new HTML("<p style='color:initial'>" + text + "</p>").getHTML());
//
// set icon cursor // // set icon cursor
infoIconDescription.getElement().getStyle().setCursor(Cursor.HELP); // infoIconDescription.getElement().getStyle().setCursor(Cursor.HELP);
} // }
} //}

View File

@ -1,4 +1,4 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> <!-- <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"> xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
@ -6,19 +6,24 @@
.important { .important {
font-weight: bold; font-weight: bold;
} }
.div-inline{
display: inline; .div-inline {
position: relative;
}
.the-font-size {
font-size: 1.3em;
} }
</ui:style> </ui:style>
<g:HTMLPanel addStyleNames="{style.div-inline}"> <g:HTMLPanel addStyleNames="{style.div-inline}">
<span style="float:right; width:5%; color: #aaaaaa;"> <div style="width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverDescription" html="true" <b:Popover ui:field="popoverDescription" html="true"
animation="true" placement="LEFT"> animation="true" placement="RIGHT">
<g:FocusPanel ui:field="focusPanelDescription"> <g:FocusPanel ui:field="focusPanelDescription">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" <b:Icon type="INFO_SIGN" ui:field="infoIconDescription"
ui:field="infoIconDescription" /> addStyleNames="{style.the-font-size}" />
</g:FocusPanel> </g:FocusPanel>
</b:Popover> </b:Popover>
</span> </div>
</g:HTMLPanel> </g:HTMLPanel>
</ui:UiBinder> </ui:UiBinder> -->

View File

@ -2,8 +2,11 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils;
import java.util.List; import java.util.List;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZendoPublisherWidget;
import com.github.gwtbootstrap.client.ui.Icon; import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.Popover; import com.github.gwtbootstrap.client.ui.Popover;
import com.github.gwtbootstrap.client.ui.constants.Placement;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Cursor; import com.google.gwt.dom.client.Style.Cursor;
@ -151,5 +154,25 @@ public class InfoTextAndLabels {
return value; return value;
} }
public static void addFieldDescriptionInfo(String theFieldKey, Widget widget) {
String value = CkanToZendoPublisherWidget.mapOfFieldsDescriptions.get(theFieldKey);
if(value!=null) {
String caption = theFieldKey.substring(0,1).toUpperCase()+theFieldKey.substring(1,theFieldKey.length());
setupPopover(widget, value, caption);
}
}
public static void setupPopover(Widget w, String message, String heading) {
Popover popover = new Popover();
popover.setWidget(w);
popover.setHtml(true);
popover.setText(message);
popover.setHeading(heading);
popover.setPlacement(Placement.RIGHT);
popover.reconfigure();
}
} }

View File

@ -7,7 +7,6 @@ import java.util.List;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation.BasicInformationView; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation.BasicInformationView;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;

View File

@ -115,5 +115,4 @@ public class FieldUtil {
} }
} }
} }

View File

@ -2,9 +2,7 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.server;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.concurrent.Future; import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.gcube.data.publishing.ckan2zenodo.Ckan2Zenodo; import org.gcube.data.publishing.ckan2zenodo.Ckan2Zenodo;
import org.gcube.data.publishing.ckan2zenodo.Ckan2ZenodoImpl; import org.gcube.data.publishing.ckan2zenodo.Ckan2ZenodoImpl;
@ -149,8 +147,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
zenodoItem.addFiles(resources); zenodoItem.addFiles(resources);
zenodoItem.setName(item.getItemName()); zenodoItem.setName(item.getItemName());
zenodoItem.setFieldsDescriptions(ZenodoFieldsDescriptionsReader.readProperties());
LOG.debug("Returning item: "+zenodoItem); LOG.debug("Returning item: "+zenodoItem);
return zenodoItem; return zenodoItem;
@ -182,6 +179,30 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
} }
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService#convertToZenodoItem(org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem)
*/
@Override
public Map<String, String> readFieldsDescriptions() throws Exception {
try {
if(isOutFromPortal()) {
PortalUtils.getCurrentContext(this.getThreadLocalRequest(), true);
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
}
return ZenodoFieldsDescriptionsReader.readProperties();
} catch (Exception e) {
String error = "Unable to read the file of properties with the fields desciptions";
LOG.error(error, e);
String clientError = String.format("%s. %s", error, e.getMessage());
throw new Exception(clientError);
}
}
/** /**
* Load item preview from service. * Load item preview from service.

View File

@ -1,7 +1,11 @@
#Property file to read the fields descriptions to show on GUI side #Property file to read the fields descriptions to show on GUI side
title = Title of deposition. title=Title of deposition.
description = Abstract or description for deposition. description=Abstract or description for deposition.
creators = The creators/authors of the deposition. Name of creator (is required) in the format Family name, Given names creators= he creators/authors of the deposition. Name of creator (is required) in the format Family name, Given names
access_right = open: Open Access, embargoed: Embargoed Access, restricted: Restricted Access, closed: Closed Access Defaults to open. access_right=Controlled vocabulary: <br>* open: Open Access<br>* embargoed: Embargoed Access<br>* restricted: Restricted Access<br>* closed: Closed Access Defaults to open.
license = The selected license applies to all files in this deposition, but not to the metadata which is licensed under Creative Commons Zero. Further information about licenses is available at Open Definition Licenses Service. Defaults to cc-by for non-datasets and cc-zero for datasets. license=The selected license applies to all files in this deposition, but not to the metadata which is licensed under Creative Commons Zero. Further information about licenses is available at Open Definition Licenses Service. Defaults to cc-by for non-datasets and cc-zero for datasets.
contributors = The contributors of the deposition (e.g. editors, data curators, etc.). Name of creator (is required) in the format Family name, Given names contributors=The contributors of the deposition (e.g. editors, data curators, etc.). Name of creator (is required) in the format Family name, Given names
upload_type=Controlled vocabulary: <br>* publication: Publication<br>* poster: Poster<br>* presentation: Presentation<br>* dataset: Dataset, etc.
publication_type=Controlled vocabulary: <br>* annotationcollection: Annotation collection<br>* book: Book<br>* section: Book section<br>* conferencepaper: Conference paper<br>* datamanagementplan: Data management plan<br>* article: Journal article, etc.
publication_date=Date of publication in ISO8601 format (YYYY-MM-DD). Defaults to current date.
keywords=Free form keywords for this deposition.

View File

@ -2,9 +2,7 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* The Class ZenodoItem. * The Class ZenodoItem.
@ -34,8 +32,6 @@ public class ZenodoItem implements Serializable {
private String title; private String title;
private String name; //this is the dataset name private String name; //this is the dataset name
private Map<String, String> fieldsDescriptions;
/** /**
* Instantiates a new zenodo item. * Instantiates a new zenodo item.
*/ */
@ -280,29 +276,6 @@ public class ZenodoItem implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/**
* Sets the fields descriptions.
*
* @param mapOfFieldsDescriptions the map of fields descriptions
*/
public void setFieldsDescriptions(Map<String, String> mapOfFieldsDescriptions) {
this.fieldsDescriptions = mapOfFieldsDescriptions;
}
/**
* Gets the fields descriptions.
*
* @return the fields descriptions
*/
public Map<String, String> getFieldsDescriptions() {
if(fieldsDescriptions == null)
return new HashMap<String, String>();
return fieldsDescriptions;
}
/* (non-Javadoc) /* (non-Javadoc)