diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.java index f2888ba..a5ee649 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.java @@ -1,16 +1,14 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.action; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync; +import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEvent; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean; import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon; import com.github.gwtbootstrap.client.ui.AlertBlock; import com.github.gwtbootstrap.client.ui.Button; -import com.github.gwtbootstrap.client.ui.Icon; import com.github.gwtbootstrap.client.ui.constants.AlertType; -import com.github.gwtbootstrap.client.ui.constants.IconType; import com.google.gwt.core.client.GWT; -import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.uibinder.client.UiBinder; @@ -41,9 +39,9 @@ public class DeleteItemPanel extends Composite { private FlowPanel alertPanel = new FlowPanel(); - private Icon iconSpinner = new Icon(IconType.SPINNER); + // private Icon iconSpinner = new Icon(IconType.SPINNER); - private HandlerManager mainApplicationBusRef; + private HandlerManager eventBusMainApplication; private final CKanPublisherServiceAsync ckanServices = CKanPublisherServiceAsync.Util.getInstance(); @@ -56,19 +54,13 @@ public class DeleteItemPanel extends Composite { private DatasetBean selectedDataset; - public DeleteItemPanel(HandlerManager mainApplicationBusRef, String datasetIdOrName) { + public DeleteItemPanel(HandlerManager eventBusMainApp, String datasetIdOrName) { initWidget(uiBinder.createAndBindUi(this)); this.datasetIdOrName = datasetIdOrName; - this.mainApplicationBusRef = mainApplicationBusRef; + this.eventBusMainApplication = eventBusMainApp; - iconSpinner.setSpin(true); - iconSpinner.getElement().getStyle().setMarginLeft(5, Unit.PX); - iconSpinner.getElement().getStyle().setProperty("animation", "spin 1s infinite linear"); - alertPanel.add(iconSpinner); infoBlock.add(alertPanel); - infoBlock.setVisible(true); - LoaderIcon loaderIcon = new LoaderIcon("Checking your permissions..."); setAlertBlock(null, loaderIcon, AlertType.INFO, true); @@ -99,10 +91,8 @@ public class DeleteItemPanel extends Composite { public void onSuccess(DatasetBean result) { setAlertBlock("", null, null, false); panelConfirm.setVisible(true); - selectedDataset = result; - - deleteMessage.add(new HTML("
" + result.getTitle() + "
")); + deleteMessage.add(new HTML("

" + result.getTitle() + "
")); } }); @@ -119,6 +109,7 @@ public class DeleteItemPanel extends Composite { LoaderIcon loaderIcon = new LoaderIcon("Deleting the item...."); setAlertBlock(null, loaderIcon, AlertType.INFO, true); + panelConfirm.setVisible(false); ckanServices.deleteItem(selectedDataset, new AsyncCallback() { @Override @@ -131,10 +122,12 @@ public class DeleteItemPanel extends Composite { @Override public void onSuccess(Boolean result) { if (result) { - setAlertBlock("Item deleted correclty", null, AlertType.INFO, true); + setAlertBlock("Item '" + selectedDataset.getTitle() + "' permanently deleted!", null, + AlertType.SUCCESS, true); + eventBusMainApplication.fireEvent(new ReloadDatasetPageEvent(null)); } else { - setAlertBlock("Sorry, I cannot delete the item. Please contact the support", null, AlertType.INFO, - true); + setAlertBlock("Sorry, I cannot delete the item. Refresh and retry or contact the support", null, + AlertType.INFO, true); } } diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.ui.xml index 2d27d07..b636a80 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.ui.xml @@ -21,16 +21,16 @@ } - + addStyleNames="{style.block-alert-style}"> - Do you want to delete the item? + Do you want to permanently delete the item? Delete + addStyleNames="{style.float-right}">Permanently delete \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java index 98df167..25cf383 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java @@ -386,6 +386,7 @@ public class CreateDatasetForm extends Composite { iconSpinner.setSpin(true); iconSpinner.getElement().getStyle().setMarginLeft(5, Unit.PX); iconSpinner.getElement().getStyle().setProperty("animation", "spin 1s infinite linear"); + infoBlock.add(alertPanel); List listOfSteps = null; if (isWorkspaceRequest) { 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 215e228..f41e7a7 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 @@ -718,106 +718,6 @@ public class UpdateDatasetForm extends Composite { } } - /** - * When the organization name is changed we need to retrieve the list of - * profiles and groups. - * - * @param operation the operation - */ - - // 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); - * - * } }); - * - * } - */ - /** * Add the items to the listbox and put data into the metadataPanel. * diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.ui.xml index 243c30c..fad55f6 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.ui.xml @@ -70,7 +70,7 @@ + addStyleNames="{style.block-alert-style}"> diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddResourceToDataset.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddResourceToDataset.java index b10e379..84b0957 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddResourceToDataset.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddResourceToDataset.java @@ -228,6 +228,9 @@ public class AddResourceToDataset extends Composite { } else showAlert("Unable to add this resource. Check that the url is correct", null, AlertType.ERROR, true, true); + + + addResourceButton.setEnabled(true); } @@ -236,6 +239,8 @@ public class AddResourceToDataset extends Composite { infoPanel.clear(); showAlert("Unable to add this resource, sorry. Error is: " + caught.getMessage(), null, AlertType.ERROR, true, true); + + addResourceButton.setEnabled(true); } });