2013-11-12 15:35:04 +01:00
|
|
|
package org.gcube.portlets.user.td.widgetcommonevent.client;
|
|
|
|
|
2013-12-02 20:01:07 +01:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.RibbonEvent;
|
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.RibbonType;
|
2013-11-12 15:35:04 +01:00
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import com.google.gwt.junit.client.GWTTestCase;
|
2013-11-12 18:27:44 +01:00
|
|
|
import com.google.web.bindery.event.shared.SimpleEventBus;
|
2013-11-12 15:35:04 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-15 11:32:43 +02:00
|
|
|
* Test Event
|
2013-11-12 15:35:04 +01:00
|
|
|
*
|
2019-10-15 11:32:43 +02:00
|
|
|
* @author Giancarlo Panichi
|
2017-05-16 16:35:52 +02:00
|
|
|
*
|
2013-11-12 18:27:44 +01:00
|
|
|
*
|
2013-11-12 15:35:04 +01:00
|
|
|
*/
|
|
|
|
public class GwtTestWidgetCommonEvent extends GWTTestCase {
|
|
|
|
|
2019-10-15 11:32:43 +02:00
|
|
|
/**
|
|
|
|
* Must refer to a valid module that sources this class.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String getModuleName() {
|
|
|
|
return "org.gcube.portlets.user.td.widgetcommonevent.WidgetCommonEventJUnit";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test Events fire
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void testEvents() {
|
2019-10-15 12:19:16 +02:00
|
|
|
System.out.println("Test Ribbon Event");
|
2019-10-15 11:32:43 +02:00
|
|
|
SimpleEventBus eventBus = new SimpleEventBus();
|
|
|
|
|
|
|
|
eventBus.addHandler(RibbonEvent.TYPE, new RibbonEvent.RibbonEventHandler() {
|
|
|
|
|
|
|
|
public void onRibbon(RibbonEvent event) {
|
|
|
|
doRibbonCommand(event);
|
2013-11-12 15:35:04 +01:00
|
|
|
|
2019-10-15 11:32:43 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
eventBus.fireEvent(new RibbonEvent(RibbonType.IMPORT_SDMX));
|
|
|
|
eventBus.fireEvent(new RibbonEvent(RibbonType.IMPORT_CSV));
|
|
|
|
eventBus.fireEvent(new RibbonEvent(RibbonType.IMPORT_JSON));
|
|
|
|
|
|
|
|
}
|
2013-11-12 15:35:04 +01:00
|
|
|
|
2019-10-15 11:32:43 +02:00
|
|
|
private void doRibbonCommand(RibbonEvent event) {
|
2013-12-02 20:01:07 +01:00
|
|
|
System.out.println("doRibbonCommand Type: " + event.getRibbonType());
|
2013-11-12 18:27:44 +01:00
|
|
|
try {
|
2013-12-02 20:01:07 +01:00
|
|
|
switch (event.getRibbonType()) {
|
2015-02-09 15:33:42 +01:00
|
|
|
case IMPORT_SDMX:
|
2013-11-12 18:27:44 +01:00
|
|
|
System.out.println("Start Import SDMX");
|
|
|
|
break;
|
2015-02-09 15:33:42 +01:00
|
|
|
case IMPORT_CSV:
|
2013-11-12 18:27:44 +01:00
|
|
|
System.out.println("Start Import CSV");
|
|
|
|
break;
|
2015-02-09 15:33:42 +01:00
|
|
|
case IMPORT_JSON:
|
2013-11-12 18:27:44 +01:00
|
|
|
System.out.println("Start Import JSON");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
2019-10-15 11:32:43 +02:00
|
|
|
System.out.println("doRibbonCommand Error : " + e.getLocalizedMessage() + " \n " + e.getMessage());
|
2013-11-12 18:27:44 +01:00
|
|
|
}
|
|
|
|
}
|
2013-11-12 15:35:04 +01:00
|
|
|
|
|
|
|
}
|