From a5efc60c576a94854bd0f5c3d09e51fe109c0731 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 13 Feb 2024 17:00:47 +0100 Subject: [PATCH] Updated the ShowDatasetsEvents --- .../client/CkanEventHandlerManager.java | 60 +++++++++-------- .../client/event/IFrameInstanciedEvent.java | 30 ++++++--- .../event/IFrameInstanciedEventHandler.java | 10 ++- .../client/event/ShowDatasetsEvent.java | 65 +++++++++++++++---- 4 files changed, 107 insertions(+), 58 deletions(-) diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/CkanEventHandlerManager.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/CkanEventHandlerManager.java index c8165f3..65304f9 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/CkanEventHandlerManager.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/CkanEventHandlerManager.java @@ -39,6 +39,8 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModerat import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorWidgetTrusted; import org.gcube.portlets.widgets.ckancontentmoderator.client.ContentModeratorWidgetConstants; import org.gcube.portlets.widgets.ckancontentmoderator.shared.DISPLAY_FIELD; +import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEvent; +import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEventHandler; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form.CreateDatasetForm; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form.UpdateDatasetForm; import org.gcube.portlets_widgets.catalogue_sharing_widget.client.ShareCatalogueWidget; @@ -96,6 +98,7 @@ public class CkanEventHandlerManager { } }); + // bind on insert metadata eventBus.addHandler(InsertMetadataEvent.TYPE, new InsertMetadataEventHandler() { @@ -131,15 +134,6 @@ public class CkanEventHandlerManager { modal.show(); } }); - // bind on edit (TODO) - eventBus.addHandler(EditMetadataEvent.TYPE, new EditMetadataEventHandler() { - - @Override - public void onEditMetadata(EditMetadataEvent editMetadataEvent) { - - // TODO Auto-generated method stub - } - }); // show datasets event eventBus.addHandler(ShowDatasetsEvent.TYPE, new ShowDatasetsEventHandler() { @@ -147,14 +141,35 @@ public class CkanEventHandlerManager { @Override public void onShowDatasets(ShowDatasetsEvent showUserDatasetsEvent) { String request = null; - if (showUserDatasetsEvent.isOwnOnly()) - request = getCkanRequest("/dashboard/datasets", null); - else - request = getCkanRequest("/dataset", null); + + if (showUserDatasetsEvent.getDatasetId() == null) { + if (showUserDatasetsEvent.isOwnOnly()) { + request = getCkanRequest("/dashboard/datasets", null); + } else { + request = getCkanRequest("/dataset", null); + } + } else { + String datasetId = showUserDatasetsEvent.getDatasetId(); + request = getCkanRequest("/dataset/" + datasetId, null); + + } gcubeCkanDataCatalogue.instanceCkanFrame(request); } }); + // ReloadDatasetPageEvent is declared in the Publisher Widget + eventBus.addHandler(ReloadDatasetPageEvent.TYPE, new ReloadDatasetPageEventHandler() { + + @Override + public void onReloadDatasetPage(ReloadDatasetPageEvent addResourceEvent) { + + if (addResourceEvent.getDatasetIDorName() != null) { + eventBus.fireEvent(new ShowDatasetsEvent(false, addResourceEvent.getDatasetIDorName())); + } + + } + }); + eventBus.addHandler(ShowTypesEvent.TYPE, new ShowTypesEventHandler() { @Override @@ -312,7 +327,7 @@ public class CkanEventHandlerManager { @Override public void onEditMetadata(EditMetadataEvent editMetadataEvent) { GWT.log("onEditMetadata called"); - + if (editMetadataEvent.getItemID() != null) { GWT.log("editMetadataEvent: " + editMetadataEvent); @@ -325,27 +340,10 @@ public class CkanEventHandlerManager { modal.add(new UpdateDatasetForm(eventBus, editMetadataEvent.getItemID())); modal.setCloseVisible(true); -// // hide any popup gcubeCkanDataCatalogue opened -// modal.addHideHandler(new HideHandler() { - // -// @Override -// public void onHide(HideEvent hideEvent) { -// GWT.log("HideEvent on modal fired"); -// GWT.log(hideEvent.toDebugString()); -// eventBus.fireEvent(new CloseCreationFormProfileEvent()); -// -// hideEvent.preventDefault(); -// hideEvent.stopPropagation(); -// return; -// -// } -// }); - GWT.log("show"); modal.show(); } - } }); } diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/event/IFrameInstanciedEvent.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/event/IFrameInstanciedEvent.java index 332b54f..fa6e229 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/event/IFrameInstanciedEvent.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/event/IFrameInstanciedEvent.java @@ -2,25 +2,28 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event; import com.google.gwt.event.shared.GwtEvent; - - /** - * The Class NotifyLogoutEvent. + * The Class IFrameInstanciedEvent. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Jun 23, 2016 + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 23, 2016 */ public class IFrameInstanciedEvent extends GwtEvent { public static Type TYPE = new Type(); - /** * Instantiates a new insert metadata event. */ public IFrameInstanciedEvent() { } - /* (non-Javadoc) + /** + * Gets the associated type. + * + * @return the associated type + */ + /* + * (non-Javadoc) + * * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() */ @Override @@ -28,8 +31,17 @@ public class IFrameInstanciedEvent extends GwtEvent{ - +public class ShowDatasetsEvent extends GwtEvent { + public static Type TYPE = new Type(); - + private boolean ownOnly; - + + private String datasetId; + /** * Instantiates a new show user datasets event. + * + * @param ownOnly the own only */ public ShowDatasetsEvent(boolean ownOnly) { - this.ownOnly = ownOnly; - } - + + /** + * Instantiates a new show user datasets event. + * + * @param ownOnly the own only + * @param datasetId the dataset id + */ + public ShowDatasetsEvent(boolean ownOnly, String datasetId) { + this.ownOnly = ownOnly; + this.datasetId = datasetId; + } + + /** + * Checks if is own only. + * + * @return true, if is own only + */ public boolean isOwnOnly() { return ownOnly; } - /* (non-Javadoc) + /** + * Gets the associated type. + * + * @return the associated type + */ + /* + * (non-Javadoc) + * * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() */ @Override @@ -33,12 +61,25 @@ public class ShowDatasetsEvent extends GwtEvent{ return TYPE; } - /* (non-Javadoc) - * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + /** + * Dispatch. + * + * @param handler the handler + */ + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared. + * EventHandler) */ @Override protected void dispatch(ShowDatasetsEventHandler handler) { handler.onShowDatasets(this); } + + public String getDatasetId() { + return datasetId; + } }