Added dedicated EventBus. Separated from Portlet EventBus
This commit is contained in:
parent
0417f98149
commit
89ae69d54b
|
@ -0,0 +1,50 @@
|
|||
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class ReloadDatasetPageEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Feb 13, 2024
|
||||
*/
|
||||
public class ReloadDatasetPageEvent extends GwtEvent<ReloadDatasetPageEventHandler> {
|
||||
public static Type<ReloadDatasetPageEventHandler> TYPE = new Type<ReloadDatasetPageEventHandler>();
|
||||
|
||||
private String datasetIDorName;
|
||||
|
||||
/**
|
||||
* Instantiates a new reload dataset page event.
|
||||
*
|
||||
* @param resource the resource
|
||||
*/
|
||||
public ReloadDatasetPageEvent(String datasetIDorName) {
|
||||
this.datasetIDorName = datasetIDorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
@Override
|
||||
public Type<ReloadDatasetPageEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(ReloadDatasetPageEventHandler handler) {
|
||||
handler.onReloadDatasetPage(this);
|
||||
}
|
||||
|
||||
public String getDatasetIDorName() {
|
||||
return datasetIDorName;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
/**
|
||||
* The Interface ReloadDatasetPageEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Feb 13, 2024
|
||||
*/
|
||||
public interface ReloadDatasetPageEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On added resource.
|
||||
*
|
||||
* @param addResourceEvent the add resource event
|
||||
*/
|
||||
void onReloadDatasetPage(ReloadDatasetPageEvent addResourceEvent);
|
||||
}
|
|
@ -274,7 +274,10 @@ public class CreateDatasetForm extends Composite {
|
|||
private List<LicenseBean> licenseBean;
|
||||
|
||||
// event bus
|
||||
private HandlerManager eventBus;
|
||||
private HandlerManager eventBusPublisherWidget = new HandlerManager(null);
|
||||
|
||||
// event bus of the principal application (it is the Catalogue Portlet)
|
||||
private HandlerManager eventBusMainApplication;
|
||||
|
||||
// added custom field entries (by the user)
|
||||
private List<CustomFieldEntry> customFieldEntriesList = new ArrayList<CustomFieldEntry>();
|
||||
|
@ -305,29 +308,29 @@ public class CreateDatasetForm extends Composite {
|
|||
/**
|
||||
* Invoked in the most general case
|
||||
*
|
||||
* @param eventBus the event bus
|
||||
* @param eventBusPublisherWidget the event bus
|
||||
*/
|
||||
public CreateDatasetForm(HandlerManager eventBus) {
|
||||
createDatasetFormBody(false, null, eventBus, OPERATION.NEW);
|
||||
public CreateDatasetForm(HandlerManager eventBusMainApplication) {
|
||||
createDatasetFormBody(false, null, eventBusMainApplication, OPERATION.NEW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked in the most general case
|
||||
*
|
||||
* @param eventBus the event bus
|
||||
* @param eventBusPublisherWidget the event bus
|
||||
*/
|
||||
public CreateDatasetForm(HandlerManager eventBus, OPERATION operation) {
|
||||
createDatasetFormBody(false, null, eventBus, operation);
|
||||
public CreateDatasetForm(HandlerManager eventBusMainApplication, OPERATION operation) {
|
||||
createDatasetFormBody(false, null, eventBusMainApplication, operation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the workspace is used
|
||||
*
|
||||
* @param idFolderWorkspace
|
||||
* @param eventBus the event bus
|
||||
* @param eventBusPublisherWidget the event bus
|
||||
*/
|
||||
public CreateDatasetForm(String idFolderOrFileWorkspace, HandlerManager eventBus) {
|
||||
createDatasetFormBody(true, idFolderOrFileWorkspace, eventBus, OPERATION.NEW);
|
||||
public CreateDatasetForm(String idFolderOrFileWorkspace, HandlerManager eventBusMainApplication) {
|
||||
createDatasetFormBody(true, idFolderOrFileWorkspace, eventBusMainApplication, OPERATION.NEW);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -335,7 +338,7 @@ public class CreateDatasetForm extends Composite {
|
|||
*/
|
||||
private void bind() {
|
||||
// when a custom field is removed, remove it from the list
|
||||
eventBus.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
|
||||
eventBusPublisherWidget.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onRemoveEntry(DeleteCustomFieldEvent event) {
|
||||
|
@ -345,7 +348,7 @@ public class CreateDatasetForm extends Composite {
|
|||
});
|
||||
|
||||
// on close form
|
||||
eventBus.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
|
||||
eventBusPublisherWidget.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
|
||||
@Override
|
||||
public void onClose(CloseCreationFormEvent event) {
|
||||
InfoIconsLabels.closeDialogBox(popupOpenedIds);
|
||||
|
@ -359,13 +362,13 @@ public class CreateDatasetForm extends Composite {
|
|||
* @param isWorkspaceRequest
|
||||
* @param idFolderWorkspace
|
||||
* @param owner
|
||||
* @param eventBus
|
||||
* @param eventBusPublisherWidget
|
||||
*/
|
||||
private void createDatasetFormBody(final boolean isWorkspaceRequest, final String idFolderOrFileWorkspace,
|
||||
final HandlerManager eventBus, final OPERATION operation) {
|
||||
final HandlerManager eventBusMainApplication, final OPERATION operation) {
|
||||
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.eventBus = eventBus;
|
||||
this.eventBusMainApplication = eventBusMainApplication;
|
||||
this.isWorkspaceRequest = isWorkspaceRequest;
|
||||
|
||||
iconSpinner.setSpin(true);
|
||||
|
@ -460,8 +463,8 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
for (String value : values) {
|
||||
// these are fixed key, variable value custom fields
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, entry.getKey(),
|
||||
value, false);
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBusPublisherWidget,
|
||||
entry.getKey(), value, false);
|
||||
customFieldEntriesList.add(toAdd);
|
||||
customFields.add(toAdd);
|
||||
|
||||
|
@ -856,10 +859,10 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
if (categories == null || categories.isEmpty()) {
|
||||
for (MetadataFieldWrapper field : fields) {
|
||||
|
||||
|
||||
MetaDataField fieldWidget;
|
||||
try {
|
||||
fieldWidget = new MetaDataField(field, eventBus, operation);
|
||||
fieldWidget = new MetaDataField(field, eventBusPublisherWidget, operation);
|
||||
metadataFieldsPanel.add(fieldWidget);
|
||||
listOfMetadataFields.add(fieldWidget);
|
||||
} catch (Exception e) {
|
||||
|
@ -883,7 +886,8 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
MetaDataField fieldWidget;
|
||||
try {
|
||||
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBus, operation);
|
||||
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBusPublisherWidget,
|
||||
operation);
|
||||
cp.addField(fieldWidget);
|
||||
listOfMetadataFields.add(fieldWidget);
|
||||
} catch (Exception e) {
|
||||
|
@ -900,7 +904,7 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
MetaDataField fieldWidget;
|
||||
try {
|
||||
fieldWidget = new MetaDataField(field, eventBus, operation);
|
||||
fieldWidget = new MetaDataField(field, eventBusPublisherWidget, operation);
|
||||
extrasCategory.addField(fieldWidget);
|
||||
listOfMetadataFields.add(fieldWidget);
|
||||
} catch (Exception e) {
|
||||
|
@ -917,7 +921,7 @@ public class CreateDatasetForm extends Composite {
|
|||
@UiHandler("addCustomFieldButton")
|
||||
void addCustomFieldEvent(ClickEvent e) {
|
||||
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, "", "", true);
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBusPublisherWidget, "", "", true);
|
||||
customFieldEntriesList.add(toAdd);
|
||||
customFields.add(toAdd);
|
||||
|
||||
|
@ -1252,7 +1256,8 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
// remove content of the main panel
|
||||
createDatasetMainPanel.clear();
|
||||
ManageResources manageResources = new ManageResources(eventBus, createdDatasetBean, datasetUrl);
|
||||
ManageResources manageResources = new ManageResources(eventBusPublisherWidget,
|
||||
createdDatasetBean, datasetUrl);
|
||||
createDatasetMainPanel.add(manageResources);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -18,6 +18,8 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCre
|
|||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEventHandler;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEvent;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
||||
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.metadata.CustomFieldEntry;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.ManageResources;
|
||||
|
@ -291,8 +293,10 @@ public class UpdateDatasetForm extends Composite {
|
|||
// the licenses
|
||||
private List<LicenseBean> licenseBean;
|
||||
|
||||
// event bus
|
||||
private HandlerManager eventBus;
|
||||
// event bus of the principal application (it is the Catalogue Portlet)
|
||||
private HandlerManager eventBusMainApplication;
|
||||
|
||||
private HandlerManager eventBusPublisherWidget = new HandlerManager(null);
|
||||
|
||||
// added custom field entries (by the user)
|
||||
private List<CustomFieldEntry> customFieldEntriesList = new ArrayList<CustomFieldEntry>();
|
||||
|
@ -315,17 +319,17 @@ public class UpdateDatasetForm extends Composite {
|
|||
private WizardCreator wizCreator;
|
||||
|
||||
private boolean isWorkspaceRequest = false;
|
||||
|
||||
private String datasetIdOrName = null;
|
||||
// private DatasetBean theDataset = null;
|
||||
|
||||
/**
|
||||
* Instantiates a new update dataset form.
|
||||
*
|
||||
* @param eventBus the event bus
|
||||
* @param itemId the item id
|
||||
* @param eventBusMainApplication the event bus
|
||||
* @param itemId the item id
|
||||
*/
|
||||
public UpdateDatasetForm(HandlerManager eventBus, String itemId) {
|
||||
updateDatasetFormBody(eventBus, itemId, OPERATION.UPDATE);
|
||||
public UpdateDatasetForm(HandlerManager mainApplicationBusRef, String itemId) {
|
||||
updateDatasetFormBody(mainApplicationBusRef, itemId, OPERATION.UPDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -333,7 +337,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
*/
|
||||
private void bind() {
|
||||
// when a custom field is removed, remove it from the list
|
||||
eventBus.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
|
||||
eventBusPublisherWidget.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onRemoveEntry(DeleteCustomFieldEvent event) {
|
||||
|
@ -343,26 +347,41 @@ public class UpdateDatasetForm extends Composite {
|
|||
});
|
||||
|
||||
// on close form
|
||||
eventBus.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
|
||||
eventBusPublisherWidget.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
|
||||
@Override
|
||||
public void onClose(CloseCreationFormEvent event) {
|
||||
InfoIconsLabels.closeDialogBox(popupOpenedIds);
|
||||
}
|
||||
});
|
||||
|
||||
eventBusPublisherWidget.addHandler(ReloadDatasetPageEvent.TYPE, new ReloadDatasetPageEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onReloadDatasetPage(ReloadDatasetPageEvent addResourceEvent) {
|
||||
|
||||
// Firing the event on the main application bus
|
||||
if (addResourceEvent.getDatasetIDorName() != null) {
|
||||
eventBusMainApplication
|
||||
.fireEvent(new ReloadDatasetPageEvent(addResourceEvent.getDatasetIDorName()));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The real constructor.
|
||||
*
|
||||
* @param eventBus the event bus
|
||||
* @param datasetIdOrName the item id
|
||||
* @param operation the operation
|
||||
* @param eventBusMainApplication the event bus
|
||||
* @param datasetIdOrName the item id
|
||||
* @param operation the operation
|
||||
*/
|
||||
private void updateDatasetFormBody(final HandlerManager eventBus, final String datasetIdOrName,
|
||||
private void updateDatasetFormBody(final HandlerManager mainApplicationBusRef, final String datasetIdOrName,
|
||||
final OPERATION operation) {
|
||||
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.eventBus = eventBus;
|
||||
|
||||
this.eventBusMainApplication = mainApplicationBusRef;
|
||||
this.datasetIdOrName = datasetIdOrName;
|
||||
|
||||
iconSpinner.setSpin(true);
|
||||
|
@ -459,8 +478,8 @@ public class UpdateDatasetForm extends Composite {
|
|||
|
||||
for (String value : values) {
|
||||
// these are fixed key, variable value custom fields
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, entry.getKey(),
|
||||
value, false);
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBusPublisherWidget,
|
||||
entry.getKey(), value, false);
|
||||
customFieldEntriesList.add(toAdd);
|
||||
customFields.add(toAdd);
|
||||
|
||||
|
@ -665,7 +684,8 @@ public class UpdateDatasetForm extends Composite {
|
|||
|
||||
for (String value : values) {
|
||||
// these are fixed key, variable value custom fields
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, entry.getKey(), value, false);
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBusPublisherWidget, entry.getKey(), value,
|
||||
false);
|
||||
customFieldEntriesList.add(toAdd);
|
||||
customFields.add(toAdd);
|
||||
}
|
||||
|
@ -897,7 +917,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
|
||||
MetaDataField fieldWidget;
|
||||
try {
|
||||
fieldWidget = new MetaDataField(field, eventBus, operation);
|
||||
fieldWidget = new MetaDataField(field, eventBusPublisherWidget, operation);
|
||||
metadataFieldsPanel.add(fieldWidget);
|
||||
listOfMetadataFields.add(fieldWidget);
|
||||
} catch (Exception e) {
|
||||
|
@ -921,7 +941,8 @@ public class UpdateDatasetForm extends Composite {
|
|||
|
||||
MetaDataField fieldWidget;
|
||||
try {
|
||||
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBus, operation);
|
||||
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBusPublisherWidget,
|
||||
operation);
|
||||
cp.addField(fieldWidget);
|
||||
listOfMetadataFields.add(fieldWidget);
|
||||
} catch (Exception e) {
|
||||
|
@ -938,7 +959,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
|
||||
MetaDataField fieldWidget;
|
||||
try {
|
||||
fieldWidget = new MetaDataField(field, eventBus, operation);
|
||||
fieldWidget = new MetaDataField(field, eventBusPublisherWidget, operation);
|
||||
extrasCategory.addField(fieldWidget);
|
||||
listOfMetadataFields.add(fieldWidget);
|
||||
} catch (Exception e) {
|
||||
|
@ -960,7 +981,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
@UiHandler("addCustomFieldButton")
|
||||
void addCustomFieldEvent(ClickEvent e) {
|
||||
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, "", "", true);
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBusPublisherWidget, "", "", true);
|
||||
customFieldEntriesList.add(toAdd);
|
||||
customFields.add(toAdd);
|
||||
|
||||
|
@ -1336,7 +1357,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
GWT.log("bindManageResources on dataset: " + theDatasetBean.getCkanName());
|
||||
|
||||
if (step == 1) {
|
||||
//addResourcesButtonStep1.clear();
|
||||
// addResourcesButtonStep1.clear();
|
||||
addResourcesButtonStep1.setVisible(true);
|
||||
addResourcesButtonStep1.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
@ -1350,7 +1371,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
}
|
||||
|
||||
if (step == 3) {
|
||||
//addResourcesButtonStep3.clear();
|
||||
// addResourcesButtonStep3.clear();
|
||||
addResourcesButtonStep3.setVisible(true);
|
||||
addResourcesButtonStep3.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
@ -1370,7 +1391,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
// remove content of the main panel
|
||||
createDatasetMainPanel.clear();
|
||||
|
||||
ManageResources manageResources = new ManageResources(eventBus, theDatasetBean, datasetUrl);
|
||||
ManageResources manageResources = new ManageResources(eventBusPublisherWidget, theDatasetBean, datasetUrl);
|
||||
|
||||
// form container
|
||||
// AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
||||
|
|
Loading…
Reference in New Issue