97 lines
2.3 KiB
Java
97 lines
2.3 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
|
|
|
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.EditMetadataEvent;
|
|
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.EditMetadataEventHandler;
|
|
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.InsertMetadataEvent;
|
|
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.InsertMetadataEventHandler;
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.CreateDatasetForm;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Modal;
|
|
import com.google.gwt.core.client.GWT;
|
|
import com.google.gwt.event.shared.HandlerManager;
|
|
import com.google.gwt.user.client.Window;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
|
|
/**
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* Jun 10, 2016
|
|
*/
|
|
public class CkanEventHandlerManager {
|
|
|
|
private HandlerManager eventBus = new HandlerManager(null);
|
|
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public CkanEventHandlerManager() {
|
|
bind();
|
|
}
|
|
|
|
|
|
private void bind() {
|
|
|
|
// bind on insert metadata
|
|
eventBus.addHandler(InsertMetadataEvent.TYPE, new InsertMetadataEventHandler() {
|
|
|
|
@Override
|
|
public void onInsertMetadata(InsertMetadataEvent loadSelecteReleaseEvent) {
|
|
|
|
final Modal modal = new Modal(true);
|
|
|
|
// request who's doing the insert
|
|
GCubeCkanDataCatalog.service.getUser(new AsyncCallback<String>() {
|
|
|
|
@Override
|
|
public void onSuccess(String username) {
|
|
|
|
if(username != null){
|
|
modal.setTitle("Insert Metadata");
|
|
modal.addStyleName("insert-metadata-modal-style");
|
|
modal.add(new CreateDatasetForm(username));
|
|
modal.setCloseVisible(true);
|
|
modal.show();
|
|
}
|
|
else
|
|
Window.alert("Please, logout and login again then retry.");
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
|
|
Window.alert("Please, logout and login again then retry.");
|
|
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
// bind on edit (TODO)
|
|
eventBus.addHandler(EditMetadataEvent.TYPE, new EditMetadataEventHandler() {
|
|
|
|
@Override
|
|
public void onEditMetadata(EditMetadataEvent editMetadataEvent) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
* @return
|
|
*/
|
|
public HandlerManager getEventBus() {
|
|
return eventBus;
|
|
}
|
|
|
|
|
|
|
|
}
|