minor fixes on GUI

This commit is contained in:
Francesco Mangiacrapa 2020-01-27 17:56:16 +01:00
parent 9edce943b2
commit 3450eda4f2
12 changed files with 151 additions and 60 deletions

View File

@ -5,6 +5,7 @@ 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.PAGER;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.Ckan2ZenodoViewManager;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.LoaderIcon;
@ -147,7 +148,7 @@ public class CkanToZendoPublisherWidget {
erroLabel.setClose(false);
erroLabel.setType(AlertType.ERROR);
erroLabel.setText(caught.getLocalizedMessage());
modal.add(erroLabel);
modalFooter.add(erroLabel);
Button close = new Button("Close");
close.addClickHandler(new ClickHandler() {
@ -161,14 +162,39 @@ public class CkanToZendoPublisherWidget {
@Override
public void onSuccess(String result) {
buttonPublish.setEnabled(true);
buttonPublish.setEnabled(false);
basicTabPanel.getElement().getStyle().setOpacity(1.0);
modalFooter.remove(loaderPublishing);
String msg = "Publishing: \n\n"+result+"\n\nIs it right?";
Window.alert(msg);
try {
modalFooter.remove(loaderPublishing);
}catch (Exception e) {
// TODO: handle exception
}
String msg = "The item has been uploaded to Zenodo correctly";
Alert infoLabel = new Alert();
infoLabel.setClose(false);
infoLabel.setType(AlertType.INFO);
infoLabel.setText(msg);
modalFooter.add(infoLabel);
}
});
}else {
basicTabPanel.managePager(PAGER.BACK); //TO SHOW THE FIELD MISSING
// Alert infoLabel = new Alert(true);
// infoLabel.setAnimation(true);
// infoLabel.set
// infoLabel.setType(AlertType.WARNING);
// infoLabel.setText("Please, check your inputs, a required field is missing...");
// modalFooter.add(infoLabel);
}
// else {
// Alert infoLabel = new Alert();
// infoLabel.setClose(false);
// infoLabel.setType(AlertType.WARNING);
// infoLabel.setText("Please, check your inputs, a required field is missing...");
// modalFooter.add(infoLabel);
// }
}
});

View File

@ -114,11 +114,18 @@ public class BasicTabPanel extends Composite {
int selectTab = tabPanel.getSelectedTab();
GWT.log("selectTab tab: "+selectTab);
GWT.log("tabPanel.getWidgetCount(): "+tabPanel.getWidgetCount());
int totatTab = tabPanel.getWidgetCount()-1;
checkPagerVisibility(selectTab);
if(direction!=null) {
int newSelectTabIndex = direction.equals(PAGER.BACK)?selectTab-1:selectTab+1;
//Checking boundary
if(newSelectTabIndex<=0)
newSelectTabIndex = 0;
if(newSelectTabIndex>totatTab)
newSelectTabIndex = totatTab;
GWT.log("newSelectTabIndex: "+newSelectTabIndex);
tabPanel.selectTab(newSelectTabIndex);
checkPagerVisibility(newSelectTabIndex);

View File

@ -108,11 +108,11 @@ public class CreatorView extends Composite {
}
if(userRole.toLowerCase().startsWith("creator")) {
InfoTextAndLabels.addFieldDescriptionInfo("creators", field_cl_author);
InfoTextAndLabels.addTooltipForFieldKey("creators", field_cl_author);
}else if(userRole.toLowerCase().startsWith("contributor")) {
InfoTextAndLabels.addFieldDescriptionInfo("contributors", field_cl_author);
InfoTextAndLabels.addTooltipForFieldKey("contributors", field_cl_author);
}else {
InfoTextAndLabels.addFieldDescriptionInfo("authors", field_cl_author);
InfoTextAndLabels.addTooltipForFieldKey("authors", field_cl_author);
}
GWT.log("Created creator view with author: "+this.author);

View File

@ -227,7 +227,7 @@ public class CreatorsFormView extends Composite implements FormValidator{
boolean isValid = FieldUtil.isValidValue(value);
if(!isValid) {
FieldUtil.setControlGroup(cgAuthor, ControlGroupType.ERROR);
return "The Name is required";
return "The field "+userRole+" Name is required";
}
/*

View File

@ -254,15 +254,20 @@ public class BasicInformationView extends Composite implements FormValidator {
private void fillForm() {
field_title.setValue(zenodoItem.getTitle());
InfoTextAndLabels.addFieldDescriptionInfo("title", cl_title);
InfoTextAndLabels.addTooltipForFieldKey("title", cl_title);
field_description.setValue(zenodoItem.getMetadata().getDescription());
InfoTextAndLabels.addFieldDescriptionInfo("description", cl_description);
field_doi.setValue(zenodoItem.getDoi().toString());
InfoTextAndLabels.addTooltipForFieldKey("description", cl_description);
field_doi.setValue(zenodoItem.getDoi());
ZenodoMetadata zMeta = zenodoItem.getMetadata();
if (zMeta != null) {
String title = zenodoItem.getTitle() != null ? zenodoItem.getTitle() : zMeta.getTitle();
field_title.setValue(title); // Re.fill title to be sure
if(zMeta.getPublication_date()!=null) {
field_publication_date.setValue(zenodoItem.getMetadata().getPublication_date());
}
// Upload type
if (zMeta.getUpload_type() != null) {
@ -270,8 +275,8 @@ public class BasicInformationView extends Composite implements FormValidator {
FieldUtil.selectValueToListBox(field_upload_type, zMeta.getUpload_type().getSelectedValues());
} else
field_upload_type.setEnabled(false);
InfoTextAndLabels.addFieldDescriptionInfo("upload_type", cl_upload_type);
InfoTextAndLabels.addTooltipForFieldKey("upload_type", cl_upload_type);
// Publication Type
if (zMeta.getPublication_type() != null) {
@ -284,7 +289,7 @@ public class BasicInformationView extends Composite implements FormValidator {
} else
cg_publication_type.setVisible(false);
InfoTextAndLabels.addFieldDescriptionInfo("publication_type", cl_publication_type);
InfoTextAndLabels.addTooltipForFieldKey("publication_type", cl_publication_type);
if(zMeta.getImage_type() != null) {
FieldUtil.addValuesToListBox(field_image_type, zMeta.getImage_type().getSelectableValues());
@ -304,7 +309,7 @@ public class BasicInformationView extends Composite implements FormValidator {
} else
field_access_right.setEnabled(false);
InfoTextAndLabels.addFieldDescriptionInfo("access_right", cl_access_right);
InfoTextAndLabels.addTooltipForFieldKey("access_right", cl_access_right);
if(zMeta.getEmbargo_date()!=null) {
embargoDate.setValue(zMeta.getEmbargo_date());
@ -312,14 +317,14 @@ public class BasicInformationView extends Composite implements FormValidator {
}else
cg_embargo_date.setVisible(false);
InfoTextAndLabels.addFieldDescriptionInfo("embargo_date", cl_embargo_date);
InfoTextAndLabels.addTooltipForFieldKey("embargo_date", cl_embargo_date);
if(zMeta.getAccess_conditions()!=null) {
field_access_conditions.setValue(zMeta.getAccess_conditions());
}else
cg_access_conditions.setVisible(false);
InfoTextAndLabels.addFieldDescriptionInfo("access_conditions", cl_access_conditions);
InfoTextAndLabels.addTooltipForFieldKey("access_conditions", cl_access_conditions);
// License
if (zMeta.getLicenses() != null) {
@ -339,7 +344,7 @@ public class BasicInformationView extends Composite implements FormValidator {
}else
field_license.setEnabled(false);
InfoTextAndLabels.addFieldDescriptionInfo("license", cl_license);
InfoTextAndLabels.addTooltipForFieldKey("license", cl_license);
// Keywords
if (zMeta.getKeywords() != null && zMeta.getKeywords().size() > 0) {
@ -410,8 +415,9 @@ public class BasicInformationView extends Composite implements FormValidator {
boolean isValid = FieldUtil.isValidValue(value);
if (!isValid) {
FieldUtil.setControlGroup(cgDOI, ControlGroupType.ERROR);
error_alert.setVisible(true);
error_alert.setText("This field DOI is required");
showErrorAlert(true, "The field DOI is required");
// error_alert.setVisible(true);
// error_alert.setText("This field DOI is required");
return "This field is required";
}
}
@ -424,8 +430,9 @@ public class BasicInformationView extends Composite implements FormValidator {
GWT.log("isValid: " + isValid);
if (!isValid) {
FieldUtil.setControlGroup(cgTitle, ControlGroupType.ERROR);
error_alert.setVisible(true);
error_alert.setText("The field Title is required");
showErrorAlert(true, "The field Title is required");
// error_alert.setVisible(true);
// error_alert.setText("The field Title is required");
return "This field is required";
}
}
@ -434,8 +441,9 @@ public class BasicInformationView extends Composite implements FormValidator {
boolean isValid = embargoDate.getValue()!=null;
if(!isValid) {
FieldUtil.setControlGroup(cg_embargo_date, ControlGroupType.ERROR);
error_alert.setVisible(true);
error_alert.setText("The field Embargo Date is required");
showErrorAlert(true, "The field Embargo Date is required");
// error_alert.setVisible(true);
// error_alert.setText("The field Embargo Date is required");
return "This field is required";
}
}
@ -444,8 +452,9 @@ public class BasicInformationView extends Composite implements FormValidator {
boolean isValid = field_access_conditions.getValue()!= null && !field_access_conditions.getValue().isEmpty();
if(!isValid) {
FieldUtil.setControlGroup(cg_access_conditions, ControlGroupType.ERROR);
error_alert.setVisible(true);
error_alert.setText("The field Access Condition is required");
showErrorAlert(true, "The field Access Condition is required");
// error_alert.setVisible(true);
// error_alert.setText("The field Access Condition is required");
return "This field is required";
}
}
@ -454,8 +463,9 @@ public class BasicInformationView extends Composite implements FormValidator {
for (CreatorsFormView cfv : listOfCreatorsView) {
String error = cfv.validateFormFields();
if (error != null) {
error_alert.setVisible(true);
error_alert.setText(error);
// error_alert.setVisible(true);
// error_alert.setText(error);
showErrorAlert(true, error);
return error;
}
}
@ -464,14 +474,26 @@ public class BasicInformationView extends Composite implements FormValidator {
for (CreatorsFormView cfv : listOfContributorsView) {
String error = cfv.validateFormFields();
if (error != null) {
error_alert.setVisible(true);
error_alert.setText(error);
showErrorAlert(true, error);
// error_alert.setVisible(true);
// error_alert.setText(error);
return error;
}
}
return null;
}
private void showErrorAlert(boolean visible, String message) {
error_alert.setText(message);
error_alert.setVisible(visible);
try {
error_alert.getElement().focus();
} catch (Exception e) {
// TODO: handle exception
}
}
/*
* (non-Javadoc)

View File

@ -40,6 +40,16 @@
</b:TextBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cg_publication_date">
<b:ControlLabel for="cl_publication_date"
ui:field="cl_publication_date">
Publication date
</b:ControlLabel>
<b:Controls>
<b2:DateBox format="dd/mm/yyyy" autoClose="true"
ui:field="field_publication_date" enabled="false" />
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cg_title">
<b:ControlLabel for="cl_title" ui:field="cl_title">
<font color="red">*</font>
@ -166,16 +176,6 @@
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cg_publication_date">
<b:ControlLabel for="cl_publication_date"
ui:field="cl_publication_date">
Publication date
</b:ControlLabel>
<b:Controls>
<b2:DateBox format="dd/mm/yyyy" autoClose="true"
ui:field="field_publication_date" />
</b:Controls>
</b:ControlGroup>
<!-- <b:Label type="INFO" ui:field="label_files" -->
<!-- addStyleNames="{style.margin-left-100}" visible="false">File/s</b:Label> -->
</b:Fieldset>

View File

@ -91,8 +91,10 @@ public class PublishFileView extends Composite {
public void hideSwitchButton(boolean bool, String msg) {
if(bool) {
switchButton.setVisible(false);
field_file_name.setEnabled(false);
}else {
switchButton.setVisible(true);
field_file_name.setEnabled(true);
}
field_label_info.setText(msg);

View File

@ -58,7 +58,7 @@ public class TagsPanel extends Composite{
tagsList.clear();
tagsPanel.clear();
InfoTextAndLabels.addFieldDescriptionInfo("keywords", cl_keywords);
InfoTextAndLabels.addTooltipForFieldKey("keywords", cl_keywords);
}

View File

@ -155,7 +155,14 @@ public class InfoTextAndLabels {
return value;
}
public static void addFieldDescriptionInfo(String theFieldKey, Widget widget) {
/**
* Adds the tooltip for field key.
*
* @param theFieldKey the the field key
* @param widget the widget
*/
public static void addTooltipForFieldKey(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());
@ -163,6 +170,13 @@ public class InfoTextAndLabels {
}
}
/**
* Setup popover.
*
* @param w the w
* @param message the message
* @param heading the heading
*/
public static void setupPopover(Widget w, String message, String heading) {
Popover popover = new Popover();
popover.setWidget(w);

View File

@ -57,7 +57,7 @@ public class Ckan2ZenodoViewManager {
boolean isUpdate = false;
if (zenodoItem.getMetadata() != null) {
isUpdate = zenodoItem.getMetadata().getDoi() != null ? true : false;
isUpdate = zenodoItem.getMetadata().getDoi() != null || zenodoItem.getDoi() != null? true : false;
}
// Basic Information
int tabIndex = 0;

View File

@ -118,7 +118,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
} catch (Exception e) {
String error = "Error during upload to Zenodo the catalogue item: "+zenodoItem.getName();
LOG.error(error, e);
String clientError = String.format("%s. %s", error, CkanToZendoPublisherWidgetConstant.MSG_OF_ERROR_REFRESH_AND_TRY_AGAIN_OR_CONTACT_THE_SUPPORT);
String clientError = String.format("%s. %s", error, e.getMessage());
throw new Exception(clientError);
}

View File

@ -456,35 +456,51 @@ public class ItemToZenodoConverter {
SerializableEnum<String> accessRight = metadata.getAccess_right();
LOG.debug("Read access type: "+accessRight);
if(accessRight!=null) {
String theAccessRightValue = accessRight.getSelectedValues().get(0);
LOG.debug("Set access right: "+theAccessRightValue);
depositionMetadata.setAccess_right(AccessRights.valueOf(theAccessRightValue));
try {
String theAccessRightValue = accessRight.getSelectedValues().get(0);
LOG.debug("Set access right: "+theAccessRightValue);
depositionMetadata.setAccess_right(AccessRights.valueOf(theAccessRightValue));
}catch (Exception e) {
LOG.warn("Set access right error: ",e);
}
}
//publication type
SerializableEnum<String> publicationType = metadata.getPublication_type();
LOG.debug("Read publication type: "+publicationType);
if(publicationType!=null) {
String thePublicationTypeValue = publicationType.getSelectedValues().get(0);
LOG.debug("Set publication type: "+thePublicationTypeValue);
depositionMetadata.setPublication_type(PublicationType.valueOf(thePublicationTypeValue));
try {
String thePublicationTypeValue = publicationType.getSelectedValues().get(0);
LOG.debug("Set publication type: "+thePublicationTypeValue);
depositionMetadata.setPublication_type(PublicationType.valueOf(thePublicationTypeValue));
}catch (Exception e) {
LOG.warn("Set publication type error: ",e);
}
}
//image type
SerializableEnum<String> imageType = metadata.getImage_type();
LOG.debug("Read image type: "+imageType);
if(imageType!=null) {
String imageTypeValue = imageType.getSelectedValues().get(0);
LOG.debug("Set image type: "+imageTypeValue);
depositionMetadata.setImage_type(ImageType.valueOf(imageTypeValue));
try {
String imageTypeValue = imageType.getSelectedValues().get(0);
LOG.debug("Set image type: "+imageTypeValue);
depositionMetadata.setImage_type(ImageType.valueOf(imageTypeValue));
}catch (Exception e) {
LOG.warn("Set image type error: ",e);
}
}
//embargo_date
Date embargoDate = metadata.getEmbargo_date();
LOG.debug("Read embargo date: "+imageType);
if(embargoDate!=null) {
LOG.debug("Set embargo date: "+embargoDate);
depositionMetadata.setEmbargo_date(embargoDate);
try {
LOG.debug("Set embargo date: "+embargoDate);
depositionMetadata.setEmbargo_date(embargoDate);
}catch (Exception e) {
LOG.warn("Set embargo date error: ",e);
}
}
//access conditions
@ -499,9 +515,13 @@ public class ItemToZenodoConverter {
SerializableEnum<LicenseBean> licenses = metadata.getLicenses();
LOG.debug("Read licenses: "+licenses);
if(licenses!=null) {
LicenseBean lB = licenses.getSelectedValues().get(0);
LOG.debug("Set license: "+lB);
depositionMetadata.setLicense(lB.getId());
try {
LicenseBean lB = licenses.getSelectedValues().get(0);
LOG.debug("Set license: "+lB);
depositionMetadata.setLicense(lB.getId());
}catch (Exception e) {
LOG.warn("Set license error: ",e);
}
}
//creators
@ -584,7 +604,7 @@ public class ItemToZenodoConverter {
theType = zenodoAuthor.getType().getSelectedValues().get(0);
type = Type.valueOf(theType);
}catch (Exception e) {
LOG.error("No able to convert "+theType + " as value of "+Type.class.getName());
LOG.error("I'm not able to convert "+theType + " as value of "+Type.class.getName());
}
contributor.setType(type);
listOfContributors.add(contributor);