Adding tooltip

This commit is contained in:
Francesco Mangiacrapa 2020-01-16 18:15:17 +01:00
parent 58e7f3e8aa
commit 6d5de0712a
11 changed files with 154 additions and 15 deletions

View File

@ -31,7 +31,7 @@ public class CkanToZendoPublisherWidget {
private CkanToZenodoPublisherServiceAsync ckanToZenodoService;
private Button buttonPublish = new Button("Publish on Zenodo");
private Button buttonPublish = new Button("Upload to Zenodo");
private Ckan2ZenodoViewManager manager = null;
private BasicTabPanel basicTabPanel;
private ModalFooter modalFooter;
@ -91,7 +91,7 @@ public class CkanToZendoPublisherWidget {
public void onClick(ClickEvent event) {
if(manager==null)
Window.alert("Sorry, the zenodo publishing is not available at this point");
Window.alert("Sorry, the upload to zenodo is not available at this point");
boolean allFormsAreValid = true;
List<FormValidator> forms = manager.getListForms();
@ -104,7 +104,7 @@ public class CkanToZendoPublisherWidget {
if(allFormsAreValid) {
buttonPublish.setEnabled(false);
basicTabPanel.getElement().getStyle().setOpacity(0.5);
final LoaderIcon loaderPublishing = new LoaderIcon("Trying to publish on Zenodo...");
final LoaderIcon loaderPublishing = new LoaderIcon("Trying to upload on Zenodo...");
modalFooter.add(loaderPublishing);
//Submit publish on zenodo.
ZenodoItem zenodoItem = manager.getZenodoItemFromFieldsForm();

View File

@ -7,6 +7,7 @@ import java.util.List;
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.utils.FieldDescription;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FieldUtil;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor;
@ -169,6 +170,14 @@ public class BasicInformationView extends Composite implements FormValidator {
ZenodoMetadata zMeta = zenodoItem.getMetadata();
if (zMeta != null) {
String title = zenodoItem.getTitle()!=null?zenodoItem.getTitle():zMeta.getTitle();
String value = zenodoItem.getFieldsDescriptions().get("title");
if(value!=null) {
Widget parent = field_title.getParent();
FieldDescription fd = new FieldDescription(null, value);
parent.getElement().appendChild(fd.getElement());
}
field_title.setValue(title); //Re.fill title to be sure
//Upload type

View File

@ -15,7 +15,7 @@
<b:Form type="HORIZONTAL">
<b:Fieldset styleName="{style.noBorder}"
ui:field="field_form_files">
<b:Legend addStyleNames="legend-style"> Choose the file/s to publish...
<b:Legend addStyleNames="legend-style"> Select the file/s to upload...
</b:Legend>
</b:Fieldset>
</b:Form>

View File

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

View File

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

View File

@ -41,7 +41,6 @@
margin-bottom: 0px;
font-size: 18px;
color: gray;
text-align: right;
}
.form-font-size .tabbable {

View File

@ -19,6 +19,7 @@ import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZendoPublisherWidgetConstant;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService;
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.configuration.ZenodoFieldsDescriptionsReader;
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.converter.ItemToZenodoConverter;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
@ -148,6 +149,8 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
zenodoItem.addFiles(resources);
zenodoItem.setName(item.getItemName());
zenodoItem.setFieldsDescriptions(ZenodoFieldsDescriptionsReader.readProperties());
LOG.debug("Returning item: "+zenodoItem);
return zenodoItem;

View File

@ -0,0 +1,40 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.server.configuration;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ZenodoFieldsDescriptionsReader {
private static final String ZENODO_FIELDS_SUGGESTIONS_PROPERTIES = "zenodo_fields_suggestions.properties";
private static Logger LOG = LoggerFactory.getLogger(ZenodoFieldsDescriptionsReader.class);
public static Map<String, String> readProperties() {
Map<String, String> map = null;
try (InputStream in = ZenodoFieldsDescriptionsReader.class.getResourceAsStream(ZENODO_FIELDS_SUGGESTIONS_PROPERTIES)) {
// load a properties file
Properties prop = new Properties();
prop.load(in);
map = new HashMap<String, String>(prop.keySet().size());
for (Object key : prop.keySet()) {
String value = (String) prop.get(key);
LOG.debug("Zenodo Field descriptor read (" + key + ", " + value +")");
map.put((String) key, (String) prop.get(key));
}
} catch (IOException e) {
LOG.error("Error occurred on reading the property file: " + ZENODO_FIELDS_SUGGESTIONS_PROPERTIES, e);
}
return map;
}
}

View File

@ -0,0 +1,7 @@
#Property file to read the fields descriptions to show on GUI side
title = Title of 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
access_right = open: Open Access, embargoed: Embargoed Access, restricted: Restricted Access, 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.
contributors = The contributors of the deposition (e.g. editors, data curators, etc.). Name of creator (is required) in the format Family name, Given names

View File

@ -2,7 +2,9 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The Class ZenodoItem.
@ -32,6 +34,8 @@ public class ZenodoItem implements Serializable {
private String title;
private String name; //this is the dataset name
private Map<String, String> fieldsDescriptions;
/**
* Instantiates a new zenodo item.
*/
@ -276,6 +280,30 @@ public class ZenodoItem implements Serializable {
public void setName(String 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)
* @see java.lang.Object#toString()
@ -313,4 +341,5 @@ public class ZenodoItem implements Serializable {
return builder.toString();
}
}

View File

@ -1,10 +0,0 @@
/** Add css rules here for your application. */
.ckan2zenodo-modal-style {
width: 800px !important;
left: -400px !important;
}
.ckan2zenodo-modal-style input {
width: 400px
}