Updated the ShowDatasetsEvents

This commit is contained in:
Francesco Mangiacrapa 2024-02-13 17:00:47 +01:00
parent 2f6ddcf2a0
commit a5efc60c57
4 changed files with 107 additions and 58 deletions

View File

@ -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();
}
}
});
}

View File

@ -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<IFrameInstanciedEventHandler> {
public static Type<IFrameInstanciedEventHandler> TYPE = new Type<IFrameInstanciedEventHandler>();
/**
* 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<IFrameInstanciedEventHandler
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(IFrameInstanciedEventHandler handler) {

View File

@ -2,17 +2,15 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface IFrameInstanciedEentHandler.
* The Interface IFrameInstanciedEventHandler.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 13, 2024
*/
public interface IFrameInstanciedEventHandler extends EventHandler {
/**
* On new instance.
*

View File

@ -3,29 +3,57 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event;
import com.google.gwt.event.shared.GwtEvent;
/**
* Raised when the user wants to see his datasets.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
* The Class ShowDatasetsEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 13, 2024
*/
public class ShowDatasetsEvent extends GwtEvent<ShowDatasetsEventHandler>{
public class ShowDatasetsEvent extends GwtEvent<ShowDatasetsEventHandler> {
public static Type<ShowDatasetsEventHandler> TYPE = new Type<ShowDatasetsEventHandler>();
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<ShowDatasetsEventHandler>{
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;
}
}