From 15232dc6b4307cfd75861c623c971622a63e6d1a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 15 Feb 2024 18:13:15 +0100 Subject: [PATCH] Updated loaders --- .../client/ui/form/UpdateDatasetForm.java | 290 +++++++++--------- .../ui/resources/AddedResourcesSummary.java | 22 +- 2 files changed, 160 insertions(+), 152 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.java index fa16cd3..4bf4d11 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.java @@ -35,6 +35,7 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetada import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel; import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton; import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel; +import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon; import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; @@ -75,7 +76,9 @@ import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FocusPanel; +import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.SimplePanel; @@ -322,6 +325,8 @@ public class UpdateDatasetForm extends Composite { private String datasetIdOrName = null; + private FlowPanel alertPanel = new FlowPanel(); + /** * Instantiates a new update dataset form. * @@ -387,6 +392,8 @@ public class UpdateDatasetForm extends Composite { iconSpinner.setSpin(true); iconSpinner.getElement().getStyle().setMarginLeft(5, Unit.PX); + infoBlock.add(alertPanel); + List listOfSteps = Arrays.asList("Edit Common Metadata", "Edit Item Specific Metadata & Update"); this.wizCreator = new WizardCreator(listOfSteps); @@ -405,7 +412,8 @@ public class UpdateDatasetForm extends Composite { tagsPanel.setVisible(false); // check if the user has publishing rights - setAlertBlock("Checking your permissions, please wait...", AlertType.INFO, true); + LoaderIcon loader = new LoaderIcon("Checking your permissions, please wait..."); + setAlertBlock(null, loader, AlertType.INFO, true); ckanServices.isPublisherOwnerOrAdminUser(this.datasetIdOrName, new AsyncCallback() { @@ -415,7 +423,9 @@ public class UpdateDatasetForm extends Composite { if (result) { // set info block - setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true); + + LoaderIcon loader = new LoaderIcon("Retrieving information, please wait..."); + setAlertBlock(null, loader, AlertType.INFO, true); // get back the licenses and the metadata information ckanServices.getDatasetBeanForUpdate(datasetIdOrName, new AsyncCallback() { @@ -423,7 +433,7 @@ public class UpdateDatasetForm extends Composite { @Override public void onFailure(Throwable caught) { - setAlertBlock(caught.getMessage(), AlertType.ERROR, true); + setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true); } @@ -432,7 +442,7 @@ public class UpdateDatasetForm extends Composite { GWT.log("getDatasetBeanForUpdate returns: " + datasetBean); if (datasetBean == null) { - setAlertBlock("Error while retrieving information.", AlertType.ERROR, true); + setAlertBlock("Error while retrieving information.", null, AlertType.ERROR, true); } else { // save it theDatasetBean = datasetBean; @@ -446,7 +456,8 @@ public class UpdateDatasetForm extends Composite { maintainerTextbox.setText(datasetBean.getMaintainer()); maintainerEmailTextbox.setText(datasetBean.getMaintainerEmail()); - setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true); + LoaderIcon loader = new LoaderIcon("Retrieving dataset information, please wait..."); + setAlertBlock(null, loader, AlertType.INFO, true); // vocabulary list of tags has preemption List vocabularyTags = datasetBean.getTagsVocabulary(); @@ -459,8 +470,8 @@ public class UpdateDatasetForm extends Composite { // // } } - - //Settings the tags + + // Settings the tags if (datasetBean.getTags() != null) { for (String tag : datasetBean.getTags()) { tagsPanel.addTagElement(tag); @@ -513,7 +524,7 @@ public class UpdateDatasetForm extends Composite { for (OrganizationBean organization : organizations) { organizationsListbox.addItem(organization.getTitle()); nameTitleOrganizationMap.put(organization.getTitle(), organization.getName()); - break; //expecting only one + break; // expecting only one } // force the selection of the first one, and retrieve the list of profiles @@ -537,7 +548,8 @@ public class UpdateDatasetForm extends Composite { theDatasetBean.setSelectedOrganization(orgName); // try to retrieve the profiles - setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true); + loader = new LoaderIcon("Retrieving types, please wait..."); + setAlertBlock(null, loader, AlertType.INFO, true); // perform remote request of profiles for the selected organization ckanServices.getProfileForUpdate(orgName, datasetBean.getChosenType(), @@ -545,13 +557,13 @@ public class UpdateDatasetForm extends Composite { @Override public void onFailure(Throwable caught) { - setAlertBlock(caught.getMessage(), AlertType.ERROR, true); + setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true); } @Override public void onSuccess( final MetadataProfileBeanForUpdate metadataProfileForUpdate) { - setAlertBlock("", AlertType.ERROR, false); + setAlertBlock("", null, AlertType.ERROR, false); List profiles = metadataProfileForUpdate .getListProfileBean(); @@ -559,7 +571,7 @@ public class UpdateDatasetForm extends Composite { if (profiles == null) { setAlertBlock( "An unknow error occurred while retrieving types, sorry", - AlertType.ERROR, true); + null, AlertType.ERROR, true); } else { GWT.log("Profile returned are: " + profiles.size()); @@ -577,18 +589,21 @@ public class UpdateDatasetForm extends Composite { metadataTypeListbox.setEnabled(true); // try to retrieve the licenses - setAlertBlock("Retrieving licenses, please wait...", AlertType.INFO, - true); + LoaderIcon loaderLic = new LoaderIcon( + "Retrieving types, please wait..."); + setAlertBlock(null, loaderLic, AlertType.INFO, true); + ckanServices.getLicenses(new AsyncCallback>() { @Override public void onFailure(Throwable caught) { - setAlertBlock(caught.getMessage(), AlertType.ERROR, true); + setAlertBlock(caught.getMessage(), null, AlertType.ERROR, + true); } @Override public void onSuccess(List licenses) { - setAlertBlock("", AlertType.ERROR, false); + setAlertBlock("", null, AlertType.ERROR, false); if (licenses != null && !licenses.isEmpty()) { @@ -602,9 +617,9 @@ public class UpdateDatasetForm extends Composite { // set the url of the license, if any showLicenseUrl(); - // try to retrieve the licenses - setAlertBlock("Retrieving groups, please wait...", - AlertType.INFO, true); + LoaderIcon loaderLic = new LoaderIcon( + "Retrieving groups, please wait..."); + setAlertBlock(null, loaderLic, AlertType.INFO, true); // request groups ckanServices.getUserGroups(orgName, @@ -616,7 +631,8 @@ public class UpdateDatasetForm extends Composite { if (groups == null) { setAlertBlock( "Error while retrieving groups", - AlertType.ERROR, true); + null, AlertType.ERROR, + true); } else { if (groups.isEmpty()) { groupsControlGroup @@ -633,8 +649,8 @@ public class UpdateDatasetForm extends Composite { profiles); } // everything went ok - setAlertBlock("", AlertType.ERROR, - false); + setAlertBlock("", null, + AlertType.ERROR, false); continueButton.setEnabled(true); resetButton.setEnabled(true); addResourcesButtonStep1 @@ -647,13 +663,13 @@ public class UpdateDatasetForm extends Composite { @Override public void onFailure(Throwable caught) { - setAlertBlock(caught.getMessage(), + setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true); } }); } else { - setAlertBlock("Error while retrieving licenses", + setAlertBlock("Error while retrieving licenses", null, AlertType.ERROR, true); } } @@ -666,14 +682,14 @@ public class UpdateDatasetForm extends Composite { }); } else { - setAlertBlock(MISSING_PUBLISH_RIGHTS, AlertType.ERROR, true); + setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.ERROR, true); } } @Override public void onFailure(Throwable caught) { - setAlertBlock(MISSING_PUBLISH_RIGHTS, AlertType.ERROR, true); + setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.ERROR, true); } }); @@ -710,119 +726,97 @@ public class UpdateDatasetForm extends Composite { */ // NEVER USED IN UPDATE MODE - /*private void organizationsListboxChangeHandlerBody(OPERATION operation) { - - // remove any other product profiles - metadataTypeListbox.clear(); - - // add "none" item again - metadataTypeListbox.addItem(NONE_PROFILE); - - // select "none" - metadataTypeListbox.setSelectedIndex(0); - - // get the name of the organization from the title - String selectedOrganizationTitle = organizationsListbox.getSelectedItemText(); - final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle); - - theDatasetBean.setSelectedOrganization(orgName); - - // try to retrieve the profiles - setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true); - - // disable the list of organizations name so that the user doesn't change it - // again - // also disable the profiles and the list of groups - organizationsListbox.setEnabled(false); - metadataTypeListbox.setEnabled(false); - groupsListbox.clear(); - groupsControlGroup.setVisible(false); - - // perform remote request of profiles for the selected organization - ckanServices.getProfiles(orgName, new AsyncCallback>() { - - @Override - public void onSuccess(final List profiles) { - - if (profiles != null) { - - theDatasetBean.setMetadataList(profiles); - prepareMetadataList(theDatasetBean, operation); - organizationsListbox.setEnabled(true); - metadataTypeListbox.setEnabled(true); - - // try to retrieve the licenses - setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true); - - // request groups - ckanServices.getUserGroups(orgName, new AsyncCallback>() { - - @Override - public void onSuccess(List groups) { - - if (groups == null) { - setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, true); - } else { - if (groups.isEmpty()) { - groupsControlGroup.setVisible(false); - } else { - - // add groups - for (OrganizationBean group : groups) { - groupsListbox.addItem(group.getTitle(), group.getName()); - } - groupsListbox.setEnabled(true); - hideGroupsAlreadyInProfile(profiles); - } - setAlertBlock("", AlertType.ERROR, false); - } - } - - @Override - public void onFailure(Throwable caught) { - setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, true); - } - }); - - // check also for tags (if for that context there is a vocabulary or not) - tagsPanel.setVisible(false); - setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, true); - ckanServices.getTagsForOrganization(orgName, new AsyncCallback>() { - - @Override - public void onSuccess(List vocabulary) { - - tagsPanel.setVocabulary(vocabulary); - tagsPanel.setVisible(true); - setAlertBlock("", AlertType.ERROR, false); - } - - @Override - public void onFailure(Throwable arg0) { - - setAlertBlock( - "Error while checking if a vocabulary of tags is defined in the selected organization.", - AlertType.ERROR, true); - tagsPanel.setVocabulary(null); - tagsPanel.setVisible(true); - - } - }); - - } else - setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, true); - - } - - @Override - public void onFailure(Throwable caught) { - - setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, true); - - } - }); - - }*/ + /* + * private void organizationsListboxChangeHandlerBody(OPERATION operation) { + * + * // remove any other product profiles metadataTypeListbox.clear(); + * + * // add "none" item again metadataTypeListbox.addItem(NONE_PROFILE); + * + * // select "none" metadataTypeListbox.setSelectedIndex(0); + * + * // get the name of the organization from the title String + * selectedOrganizationTitle = organizationsListbox.getSelectedItemText(); final + * String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle); + * + * theDatasetBean.setSelectedOrganization(orgName); + * + * // try to retrieve the profiles + * setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true); + * + * // disable the list of organizations name so that the user doesn't change it + * // again // also disable the profiles and the list of groups + * organizationsListbox.setEnabled(false); + * metadataTypeListbox.setEnabled(false); groupsListbox.clear(); + * groupsControlGroup.setVisible(false); + * + * // perform remote request of profiles for the selected organization + * ckanServices.getProfiles(orgName, new + * AsyncCallback>() { + * + * @Override public void onSuccess(final List profiles) { + * + * if (profiles != null) { + * + * theDatasetBean.setMetadataList(profiles); prepareMetadataList(theDatasetBean, + * operation); organizationsListbox.setEnabled(true); + * metadataTypeListbox.setEnabled(true); + * + * // try to retrieve the licenses + * setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true); + * + * // request groups ckanServices.getUserGroups(orgName, new + * AsyncCallback>() { + * + * @Override public void onSuccess(List groups) { + * + * if (groups == null) { + * setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, + * true); } else { if (groups.isEmpty()) { groupsControlGroup.setVisible(false); + * } else { + * + * // add groups for (OrganizationBean group : groups) { + * groupsListbox.addItem(group.getTitle(), group.getName()); } + * groupsListbox.setEnabled(true); hideGroupsAlreadyInProfile(profiles); } + * setAlertBlock("", AlertType.ERROR, false); } } + * + * @Override public void onFailure(Throwable caught) { + * setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, + * true); } }); + * + * // check also for tags (if for that context there is a vocabulary or not) + * tagsPanel.setVisible(false); + * setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, + * true); ckanServices.getTagsForOrganization(orgName, new + * AsyncCallback>() { + * + * @Override public void onSuccess(List vocabulary) { + * + * tagsPanel.setVocabulary(vocabulary); tagsPanel.setVisible(true); + * setAlertBlock("", AlertType.ERROR, false); } + * + * @Override public void onFailure(Throwable arg0) { + * + * setAlertBlock( + * "Error while checking if a vocabulary of tags is defined in the selected organization." + * , AlertType.ERROR, true); tagsPanel.setVocabulary(null); + * tagsPanel.setVisible(true); + * + * } }); + * + * } else setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, + * true); + * + * } + * + * @Override public void onFailure(Throwable caught) { + * + * setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, true); + * + * } }); + * + * } + */ /** * Add the items to the listbox and put data into the metadataPanel. @@ -1344,7 +1338,7 @@ public class UpdateDatasetForm extends Composite { // if we are in the "general case" we need to show a form for adding resources bindManageResources(createdDatasetBean, datasetUrl, 3); - + eventBusPublisherWidget.fireEvent(new ReloadDatasetPageEvent(createdDatasetBean.getId())); } else { @@ -1741,12 +1735,24 @@ public class UpdateDatasetForm extends Composite { * @param type the type * @param visible the visible */ - private void setAlertBlock(String textToShow, AlertType type, boolean visible) { + private void setAlertBlock(String textToShow, LoaderIcon loader, AlertType type, boolean visible) { - infoBlock.setText(textToShow); +// infoBlock.setText(textToShow); +// infoBlock.setType(type); +// infoBlock.setVisible(visible); + + alertPanel.clear(); + + if (loader != null) { + alertPanel.add(loader); + } infoBlock.setType(type); infoBlock.setVisible(visible); + if (textToShow != null) { + alertPanel.add(new HTML(textToShow)); + } + } /** diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.java index 8c44615..c75207b 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.java @@ -127,22 +127,23 @@ public class AddedResourcesSummary extends Composite { accordionGroup.setHeading("* " + addedResourceBean.getName()); accordionGroup.getHeading().addStyleName("accordion-resource-added"); accordion.add(accordionGroup); - + FlexTable resourceTable = new FlexTable(); resourceTable.addStyleName("resource-table"); // add sub-info such as url and description - //HTML htmlURL = new HTML(); + // HTML htmlURL = new HTML(); if (addedResourceBean.getUrl() != null) { // htmlURL.setHTML( // "URL: " + addedResourceBean.getUrl() + ""); resourceTable.setWidget(0, 0, new HTML("URL")); - resourceTable.setWidget(0, 1, new HTML("" + addedResourceBean.getUrl() + "")); + resourceTable.setWidget(0, 1, new HTML( + "" + addedResourceBean.getUrl() + "")); } - //Paragraph pDescription = new Paragraph(); - //pDescription.setText("Description : " + addedResourceBean.getDescription()); - + // Paragraph pDescription = new Paragraph(); + // pDescription.setText("Description : " + addedResourceBean.getDescription()); + resourceTable.setWidget(1, 0, new HTML("Description")); resourceTable.setWidget(1, 1, new HTML(addedResourceBean.getDescription())); @@ -160,7 +161,7 @@ public class AddedResourcesSummary extends Composite { }); // fill accordion - //accordionGroup.add(htmlURL); + // accordionGroup.add(htmlURL); accordionGroup.add(resourceTable); accordionGroup.add(deleteButton); @@ -215,7 +216,7 @@ public class AddedResourcesSummary extends Composite { addedResources.remove(toDelete); addResourcesPanel.remove(toDeleteAccordion); - //Firing event to reload the dataset page + // Firing event to reload the dataset page eventBus.fireEvent(new ReloadDatasetPageEvent( deleteResourceEvent.getResource().getCkanDatasetId())); @@ -263,11 +264,12 @@ public class AddedResourcesSummary extends Composite { alertPanel.clear(); + alertMessage.setType(type); + alertMessage.setVisible(visible); + if (loader != null) { alertPanel.add(loader); } - alertMessage.setType(type); - alertMessage.setVisible(visible); if (message != null) { alertPanel.add(new HTML(message));