Reorganized the event classes
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widget-common-event@86469 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ccdb073c42
commit
598ba13988
|
@ -1,50 +0,0 @@
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client.event;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.CloseTabularResourceType;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.HasHandlers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class CloseTabularResourceEvent extends GwtEvent<CloseTabularResourceEvent.CloseTabularResourceHandler> {
|
|
||||||
|
|
||||||
public static Type<CloseTabularResourceHandler> TYPE = new Type<CloseTabularResourceHandler>();
|
|
||||||
private CloseTabularResourceType closeType;
|
|
||||||
|
|
||||||
public interface CloseTabularResourceHandler extends EventHandler {
|
|
||||||
void onCloseTabularResource(CloseTabularResourceEvent event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloseTabularResourceEvent(CloseTabularResourceType closeType) {
|
|
||||||
this.closeType = closeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloseTabularResourceType getCloseType() {
|
|
||||||
return closeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(CloseTabularResourceHandler handler) {
|
|
||||||
handler.onCloseTabularResource(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<CloseTabularResourceHandler> getAssociatedType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type<CloseTabularResourceHandler> getType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fire(HasHandlers source, CloseTabularResourceType closeType) {
|
|
||||||
source.fireEvent(new CloseTabularResourceEvent(closeType));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client.event;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ExportTableType;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.HasHandlers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ExportTableEvent extends GwtEvent<ExportTableEvent.ExportTableHandler> {
|
|
||||||
|
|
||||||
public static Type<ExportTableHandler> TYPE = new Type<ExportTableHandler>();
|
|
||||||
private ExportTableType exportType;
|
|
||||||
|
|
||||||
public interface ExportTableHandler extends EventHandler {
|
|
||||||
void onExportTable(ExportTableEvent event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExportTableEvent(ExportTableType exportType) {
|
|
||||||
this.exportType = exportType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExportTableType getExportType() {
|
|
||||||
return exportType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(ExportTableHandler handler) {
|
|
||||||
handler.onExportTable(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<ExportTableHandler> getAssociatedType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type<ExportTableHandler> getType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fire(HasHandlers source, ExportTableType exportType) {
|
|
||||||
source.fireEvent(new ExportTableEvent(exportType));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client.event;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ImportTableType;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.HasHandlers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ImportTableEvent extends GwtEvent<ImportTableEvent.ImportTableHandler> {
|
|
||||||
|
|
||||||
public static Type<ImportTableHandler> TYPE = new Type<ImportTableHandler>();
|
|
||||||
private ImportTableType importType;
|
|
||||||
|
|
||||||
public interface ImportTableHandler extends EventHandler {
|
|
||||||
void onImportTable(ImportTableEvent event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImportTableEvent(ImportTableType importType) {
|
|
||||||
this.importType = importType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImportTableType getImportType() {
|
|
||||||
return importType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(ImportTableHandler handler) {
|
|
||||||
handler.onImportTable(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<ImportTableHandler> getAssociatedType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type<ImportTableHandler> getType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fire(HasHandlers source, ImportTableType importType) {
|
|
||||||
source.fireEvent(new ImportTableEvent(importType));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client.event;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.OpenFunctionalityType;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.HasHandlers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class OpenFunctionalityEvent extends GwtEvent<OpenFunctionalityEvent.OpenFunctionalityHandler> {
|
|
||||||
|
|
||||||
public static Type<OpenFunctionalityHandler> TYPE = new Type<OpenFunctionalityHandler>();
|
|
||||||
private OpenFunctionalityType openFunctionalityType;
|
|
||||||
|
|
||||||
public interface OpenFunctionalityHandler extends EventHandler {
|
|
||||||
void onOpenFunctionality(OpenFunctionalityEvent event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenFunctionalityEvent(OpenFunctionalityType openFunctionalityType) {
|
|
||||||
this.openFunctionalityType = openFunctionalityType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenFunctionalityType getOpenFunctionalityType() {
|
|
||||||
return openFunctionalityType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(OpenFunctionalityHandler handler) {
|
|
||||||
handler.onOpenFunctionality(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<OpenFunctionalityHandler> getAssociatedType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type<OpenFunctionalityHandler> getType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fire(HasHandlers source, OpenFunctionalityType openFunctionalityType) {
|
|
||||||
source.fireEvent(new OpenFunctionalityEvent(openFunctionalityType));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client.event;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.OpenTabularResourceType;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.HasHandlers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class OpenTabularResourceEvent extends GwtEvent<OpenTabularResourceEvent.OpenTabularResourceHandler> {
|
|
||||||
|
|
||||||
public static Type<OpenTabularResourceHandler> TYPE = new Type<OpenTabularResourceHandler>();
|
|
||||||
private OpenTabularResourceType openType;
|
|
||||||
|
|
||||||
public interface OpenTabularResourceHandler extends EventHandler {
|
|
||||||
void onOpenTabularResource(OpenTabularResourceEvent event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenTabularResourceEvent(OpenTabularResourceType openType) {
|
|
||||||
this.openType = openType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenTabularResourceType getOpenType() {
|
|
||||||
return openType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(OpenTabularResourceHandler handler) {
|
|
||||||
handler.onOpenTabularResource(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<OpenTabularResourceHandler> getAssociatedType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type<OpenTabularResourceHandler> getType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fire(HasHandlers source, OpenTabularResourceType openType) {
|
|
||||||
source.fireEvent(new OpenTabularResourceEvent(openType));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client.type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public enum CloseTabularResourceType {
|
|
||||||
TABLE;
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
|
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client.type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public enum ExportTableType {
|
|
||||||
CSV,
|
|
||||||
SDMX,
|
|
||||||
JSON;
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client.type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public enum ImportTableType {
|
|
||||||
CSV,
|
|
||||||
SDMX,
|
|
||||||
JSON;
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
|
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client.type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public enum OpenFunctionalityType {
|
|
||||||
PROPERTIES;
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client.type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public enum OpenTabularResourceType {
|
|
||||||
TABLE;
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client;
|
package org.gcube.portlets.user.td.widgetcommonevent.client;
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ImportTableEvent;
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.RibbonEvent;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ImportTableType;
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.RibbonType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.google.gwt.junit.client.GWTTestCase;
|
import com.google.gwt.junit.client.GWTTestCase;
|
||||||
|
@ -33,40 +33,41 @@ public class GwtTestWidgetCommonEvent extends GWTTestCase {
|
||||||
|
|
||||||
SimpleEventBus eventBus=new SimpleEventBus();
|
SimpleEventBus eventBus=new SimpleEventBus();
|
||||||
|
|
||||||
eventBus.addHandler(ImportTableEvent.TYPE,
|
eventBus.addHandler(RibbonEvent.TYPE,
|
||||||
new ImportTableEvent.ImportTableHandler() {
|
new RibbonEvent.RibbonEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onImportTable(ImportTableEvent event) {
|
public void onRibbon(RibbonEvent event) {
|
||||||
doImportTable(event.getImportType());
|
doRibbonCommand(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
eventBus.fireEvent(new RibbonEvent(RibbonType.IMPORTSDMX));
|
||||||
|
eventBus.fireEvent(new RibbonEvent(RibbonType.IMPORTCSV));
|
||||||
|
eventBus.fireEvent(new RibbonEvent(RibbonType.IMPORTJSON));
|
||||||
|
|
||||||
eventBus.fireEvent(new ImportTableEvent(ImportTableType.SDMX));
|
|
||||||
eventBus.fireEvent(new ImportTableEvent(ImportTableType.CSV));
|
|
||||||
eventBus.fireEvent(new ImportTableEvent(ImportTableType.JSON));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doImportTable(ImportTableType importType) {
|
private void doRibbonCommand(RibbonEvent event) {
|
||||||
System.out.println("doImportTable importType: " + importType);
|
System.out.println("doRibbonCommand Type: " + event.getRibbonType());
|
||||||
try {
|
try {
|
||||||
switch (importType) {
|
switch (event.getRibbonType()) {
|
||||||
case SDMX:
|
case IMPORTSDMX:
|
||||||
System.out.println("Start Import SDMX");
|
System.out.println("Start Import SDMX");
|
||||||
break;
|
break;
|
||||||
case CSV:
|
case IMPORTCSV:
|
||||||
System.out.println("Start Import CSV");
|
System.out.println("Start Import CSV");
|
||||||
break;
|
break;
|
||||||
case JSON:
|
case IMPORTJSON:
|
||||||
System.out.println("Start Import JSON");
|
System.out.println("Start Import JSON");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("doImportTable Error : " + e.getLocalizedMessage()
|
System.out.println("doRibbonCommand Error : " + e.getLocalizedMessage()
|
||||||
+ " \n " + e.getMessage());
|
+ " \n " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue