Update to new Client Library

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@81773 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-09-19 17:11:45 +00:00
parent fe343e78ce
commit 89b7949744
8 changed files with 208 additions and 51 deletions

View File

@ -22,9 +22,6 @@
<dependent-module archiveName="TDOpen-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/tabular-data-open/tabular-data-open">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="service-client-mock-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/service-client-mock/service-client-mock">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="tabular-data-portlet"/>
</wb-module>

View File

@ -0,0 +1,24 @@
/**
*
*/
package org.gcube.portlets.user.td.client;
/**
*/
public class Constants {
public static String VERSION = "1.0.0";
public static boolean TEST_MODE = false;
public final static String DEFAULT_USER =
(!TEST_MODE) ? "test.user" :
"giancarlo.panichi";
public static final String DEFAULT_SCOPE = "/gcube/devsec/devVRE";//"/gcube/devsec";
public static final String TD_DATASOURCE_FACTORY_ID = "TDDataSourceFactory";
public static final String APPLICATION_ID = "org.gcube.portlets.user.td.server.portlet.TabularDataPortlet";
}

View File

@ -3,28 +3,24 @@
*/
package org.gcube.portlets.user.td.client;
import org.gcube.portlets.user.sdmximportwizardtd.client.SDMXImportWizardTD;
import org.gcube.portlets.user.sdmximportwizardtd.client.general.WizardListener;
import org.gcube.portlets.user.td.ciw.client.CSVImporterWidget;
import org.gcube.portlets.user.td.client.event.CloseTabularResourceEvent;
import org.gcube.portlets.user.td.client.event.CloseTabularResourceType;
import org.gcube.portlets.user.td.client.event.ImportTableEvent;
import org.gcube.portlets.user.td.client.event.ImportTableType;
import org.gcube.portlets.user.td.client.event.OpenTabularResourceEvent;
import org.gcube.portlets.user.td.client.event.OpenTabularResourceType;
import org.gcube.portlets.user.td.importer.client.TabularDataImporterListener;
import org.gcube.portlets.user.td.open.client.TDOpen;
import org.gcube.portlets.user.sdmximportwizardtd.client.SDMXImportWizardTD;
import org.gcube.portlets.user.sdmximportwizardtd.client.general.WizardListener;
import org.gcube.portlets.user.tdw.client.TabularData;
import org.gcube.portlets.user.tdw.shared.model.TableDefinition;
import org.gcube.portlets.user.tdw.shared.model.TableId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.event.logical.shared.HasCloseHandlers;
import com.google.gwt.event.logical.shared.HasOpenHandlers;
import com.google.gwt.event.logical.shared.OpenEvent;
import com.google.gwt.event.logical.shared.OpenHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;
import com.sencha.gxt.widget.core.client.info.Info;
@ -36,6 +32,24 @@ public class TabularDataController {
//implements HasCloseHandlers<Long>, HasOpenHandlers<Long> {
protected SimpleEventBus eventBus;
protected TabularData tabularData;
/**
* Tabular Data Id
*/
protected TableId tableOpening;
/**
* Table Open
*/
protected boolean tableOpen=false;
/**
* Table Id
*/
protected String tableId;
public TabularDataController() {
eventBus = new SimpleEventBus();
@ -49,6 +63,12 @@ public class TabularDataController {
return eventBus;
}
public void setTabularData(TabularData tabularData){
this.tabularData=tabularData;
}
protected void bindToEvents() {
eventBus.addHandler(ImportTableEvent.TYPE,
new ImportTableEvent.ImportTableHandler() {
@ -66,11 +86,20 @@ public class TabularDataController {
doOpenTabularResource(event.getOpenType());
}
});
eventBus.addHandler(CloseTabularResourceEvent.TYPE,
new CloseTabularResourceEvent.CloseTabularResourceHandler() {
@Override
public void onCloseTabularResource(CloseTabularResourceEvent event) {
doCloseTabularResource(event.getCloseType());
}
});
}
public void doImportTable(ImportTableType importType) {
Log.trace("doImportTable importType: " + importType);
Info.display("ImportTableEvent", "importType: " + importType);
Info.display("Import Tabular Resource", "type: " + importType);
try {
switch (importType) {
case SDMX:
@ -86,13 +115,13 @@ public class TabularDataController {
break;
}
} catch (Exception e) {
Log.error("doImportTable Error : " + e.getLocalizedMessage()+ " \n "+e.getCause());
Log.error("doImportTable Error : " + e.getLocalizedMessage()+ " \n "+e.getMessage());
}
}
public void doOpenTabularResource(OpenTabularResourceType openType) {
Log.trace("doOpenTabularResource openType: " + openType);
Info.display("OpenTabularResourceEvent", "openType: " + openType);
Info.display("Open Tabular Resource", "open: " + openType);
try {
switch (openType) {
case TABLE:
@ -102,7 +131,24 @@ public class TabularDataController {
break;
}
} catch (Exception e) {
Log.error("doOpenTable Error : " + e.getLocalizedMessage()+ " \n "+e.getCause());
Log.error("doOpenTable Error : " + e.getLocalizedMessage()+ " \n "+e.getMessage());
}
}
public void doCloseTabularResource(CloseTabularResourceType closeType) {
Log.trace("doCloseTabularResource closeType: " + closeType);
Info.display("Close Tabular Resource", "close: " + closeType);
try {
switch (closeType) {
case TABLE:
closeTabularResources();
break;
default:
break;
}
} catch (Exception e) {
Log.error("doOpenTable Error : " + e.getLocalizedMessage()+ " \n "+e.getMessage());
}
}
@ -118,7 +164,7 @@ public class TabularDataController {
@Override
public void completed() {
//TableId importWizard.getTable(index);
//importWizard.getTable();
}
@ -164,21 +210,27 @@ public class TabularDataController {
}
/**
*
*/
protected void closeTabularResources(){
if(tableOpen) tabularData.closeTable();
}
/**
*
*/
protected void openTabularResources() {
Log.info("Open Tabular Resources");
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
TDOpen tdOpen= new TDOpen("Tabular Resources Open");
tdOpen.addListener(new org.gcube.portlets.user.td.open.client.general.WizardListener(){
@Override
public void completed() {
// TODO Auto-generated method stub
}
tdOpen.addListener(new org.gcube.portlets.user.td.open.client.general.OpenListener(){
@Override
public void aborted() {
@ -193,8 +245,17 @@ public class TabularDataController {
}
});
@Override
public void completed(String tablekey) {
tableOpening=new TableId(Constants.TD_DATASOURCE_FACTORY_ID,tablekey);
tabularData.openTable(tableOpening);
tableOpen=true;
tableId=tablekey;
}
});
Log.info("TDOpen add Listener");
tdOpen.show();
}

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.td.client;
import org.gcube.portlets.user.td.client.ribbon.TabularDataRibbon;
import org.gcube.portlets.user.td.client.rpc.TabularDataService;
import org.gcube.portlets.user.td.client.rpc.TabularDataServiceAsync;
@ -8,6 +9,7 @@ import org.gcube.portlets.user.tdw.client.TabularData;
import org.gcube.portlets.user.tdw.client.TabularDataGridPanel;
import org.gcube.portlets.user.tdw.client.event.FailureEvent;
import org.gcube.portlets.user.tdw.client.event.FailureEventHandler;
import org.gcube.portlets.user.tdw.shared.model.DataRow;
import org.gcube.portlets.user.tdw.shared.model.TableId;
import com.allen_sauer.gwt.log.client.Log;
@ -15,15 +17,18 @@ import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.ui.ResizeLayoutPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.Dialog;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.Viewport;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.info.Info;
/**
@ -46,8 +51,11 @@ public class TabularDataPortlet implements EntryPoint {
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
@SuppressWarnings("unused")
private final TabularDataServiceAsync greetingService = GWT.create(TabularDataService.class);
//Private TabularData
private static TabularData tabularData;
/**
* {@inheritDoc}
@ -74,10 +82,24 @@ public class TabularDataPortlet implements EntryPoint {
TabularDataController controller = new TabularDataController();
EventBus eventBus = controller.getEventBus();
tabularData = new TabularData(Constants.TD_DATASOURCE_FACTORY_ID);
tabularData.addFailureHandler(new FailureEventHandler() {
@Override
public void onFailure(FailureEvent event) {
Info.display("Error: "+event.getMessage(), event.getCaught().getMessage());
}
});
controller.setTabularData(tabularData);
//Layout
final BorderLayoutContainer mainPanelLayout = new BorderLayoutContainer();
mainPanelLayout.setBorders(true);
//Ribbon Menu
TabularDataRibbon tabularDataTooBar = new TabularDataRibbon(eventBus);
Widget toolBarPanel = tabularDataTooBar.getContainer();
@ -91,23 +113,16 @@ public class TabularDataPortlet implements EntryPoint {
//Grid
final TabularData tabularData = new TabularData("TDDataSourceFactory");
tabularData.addFailureHandler(new FailureEventHandler() {
@Override
public void onFailure(FailureEvent event) {
Info.display("Error: "+event.getMessage(), event.getCaught().getMessage());
}
});
final TabularDataGridPanel grid = tabularData.getGridPanel();
final TabularDataGridPanel gridPanel = tabularData.getGridPanel();
MarginData gridData = new MarginData();
mainPanelLayout.setCenterWidget(grid, gridData);
TableId tableopening=new TableId("TDDataSourceFactory","1");
/*TableId tableopening=new TableId(Constants.TD_DATASOURCE_FACTORY_ID,"1");
tabularData.openTable(tableopening);
gridPanel.setHeaderVisible(false);*/
mainPanelLayout.setCenterWidget(gridPanel, gridData);
//Main
SimpleContainer mainPanel = new SimpleContainer();
mainPanel.add(mainPanelLayout);
@ -131,4 +146,6 @@ public class TabularDataPortlet implements EntryPoint {
root.add(viewport);
}
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.user.td.client.event;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.HasHandlers;
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));
}
}

View File

@ -0,0 +1,12 @@
/**
*
*/
package org.gcube.portlets.user.td.client.event;
/**
* @author "Federico De Faveri defaveri@isti.cnr.it"
*
*/
public enum CloseTabularResourceType {
TABLE;
}

View File

@ -3,6 +3,8 @@
*/
package org.gcube.portlets.user.td.client.ribbon;
import org.gcube.portlets.user.td.client.event.CloseTabularResourceEvent;
import org.gcube.portlets.user.td.client.event.CloseTabularResourceType;
import org.gcube.portlets.user.td.client.event.ImportTableEvent;
import org.gcube.portlets.user.td.client.event.ImportTableType;
import org.gcube.portlets.user.td.client.event.OpenTabularResourceEvent;
@ -36,7 +38,7 @@ public class FileToolBar {
protected ToolBar toolBar;
protected TextButton openButton;
protected TextButton saveButton;
//protected TextButton saveButton;
protected TextButton closeButton;
protected TextButton propertiesButton;
@ -91,6 +93,7 @@ public class FileToolBar {
dataLayout.setWidget(0, 0, openButton);
dataLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
/*
saveButton = new TextButton("Save", TabularDataResources.INSTANCE.save32());
saveButton.setScale(ButtonScale.LARGE);
saveButton.setIconAlign(IconAlign.TOP);
@ -107,7 +110,7 @@ public class FileToolBar {
dataLayout.setWidget(0, 1, saveButton);
dataLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
*/
closeButton = new TextButton("Close", TabularDataResources.INSTANCE.close());
closeButton.setToolTip("Close table");
@ -116,7 +119,7 @@ public class FileToolBar {
@Override
public void onSelect(SelectEvent event) {
//eventBus.fireEvent(new ImportTableEvent(ImportTableType.CSV));
eventBus.fireEvent(new CloseTabularResourceEvent(CloseTabularResourceType.TABLE));
}
});

View File

@ -31,7 +31,7 @@ public class TabularDataServiceImpl extends RemoteServiceServlet implements Tabu
public void init() throws ServletException {
super.init();
System.out.println("initializing the TabularDataImporterManager");
System.out.println("initializing the TabularDataImportManager");
TabularDataImporterManager importerManager = new TabularDataImporterManager();
//importerManager.scanAvailableImporters();
importerManager.add(new CSVTDImporter());
@ -43,6 +43,7 @@ public class TabularDataServiceImpl extends RemoteServiceServlet implements Tabu
ScopeProvider.instance.set("/gcube/devsec");
System.out.println("initializing TDDataSourceFactory");
DataSourceFactoryRegistry.getInstance().add(new TDDataSourceFactory());
}