diff --git a/.classpath b/.classpath
index 643df01..3ca16a7 100644
--- a/.classpath
+++ b/.classpath
@@ -1,12 +1,12 @@
-
+
-
+
@@ -33,5 +33,5 @@
-
+
diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java
index 9844b1b..59e1f7a 100644
--- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java
+++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java
@@ -6,6 +6,8 @@ package org.gcube.portlets.user.td.openwidget.client;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
+import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
+import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
@@ -65,37 +67,7 @@ public class TabResourcesSelectionCard extends WizardCard {
Command sayFinish = new Command() {
public void execute() {
-
- TDGWTServiceAsync.INSTANCE.setTabResource(tdOpenSession
- .getSelectedTabResource(),
- new AsyncCallback() {
- public void onFailure(Throwable caught) {
- AlertMessageBox d = new AlertMessageBox(
- "Error", "Error on set TabResource: "
- + caught.getLocalizedMessage());
- d.addHideHandler(new HideHandler() {
-
- public void onHide(HideEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- });
- d.show();
-
- }
-
- public void onSuccess(Void result) {
- getWizardWindow().fireCompleted(tdOpenSession
- .getSelectedTabResource().getTrId());
- getWizardWindow().close(false);
- Log.info("OpenTD Tabular Resource selected :" + tdOpenSession
- .getSelectedTabResource());
- }
-
- });
-
-
+ retrieveLastTable();
}
};
@@ -104,5 +76,81 @@ public class TabResourcesSelectionCard extends WizardCard {
//getWizardWindow().setFinishCommand(sayFinish);
}
+
+ protected void retrieveLastTable(){
+ TDGWTServiceAsync.INSTANCE.getLastTable(tdOpenSession
+ .getSelectedTabResource().getTrId(), new AsyncCallback(){
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Attention", "This tabular resource does not have a valid table");
+ AlertMessageBox d = new AlertMessageBox(
+ "Attention", "This tabular resource does not have a valid table"
+ + caught.getLocalizedMessage());
+ d.addHideHandler(new HideHandler() {
+
+ public void onHide(HideEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ d.show();
+
+ }
+
+ @Override
+ public void onSuccess(TableData result) {
+ Log.debug("Retrieve last table: "+result);
+ updateTDOpenSessionInfo(result);
+ }
+
+ });
+
+ }
+
+ protected void updateTDOpenSessionInfo(TableData table){
+ TabResource tabResource=tdOpenSession.getSelectedTabResource();
+ TRId trId=tabResource.getTrId();
+ trId.setTableId(table.getTrId().getTableId());
+ trId.setTableType(table.getTrId().getTableType());
+ tabResource.setTrId(trId);
+ tdOpenSession.setSelectedTabResource(tabResource);
+ Log.debug("TdOpenSession: "+tdOpenSession);
+ setTabularResource();
+ }
+
+
+ protected void setTabularResource(){
+ TDGWTServiceAsync.INSTANCE.setTabResource(tdOpenSession
+ .getSelectedTabResource(),
+ new AsyncCallback() {
+ public void onFailure(Throwable caught) {
+ AlertMessageBox d = new AlertMessageBox(
+ "Error", "Error on set TabResource: "
+ + caught.getLocalizedMessage());
+ d.addHideHandler(new HideHandler() {
+
+ public void onHide(HideEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+ d.show();
+
+ }
+
+ public void onSuccess(Void result) {
+ getWizardWindow().fireCompleted(tdOpenSession
+ .getSelectedTabResource().getTrId());
+ getWizardWindow().close(false);
+ Log.info("OpenTD Tabular Resource selected :" + tdOpenSession
+ .getSelectedTabResource());
+ }
+
+ });
+
+
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java
index 270cdf9..dbb0530 100644
--- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java
+++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java
@@ -66,7 +66,9 @@ public class TabResourcesSelectionPanel extends ContentPanel implements HasSelec
protected static final ColumnConfig nameColumn = new ColumnConfig(properties.name(), 50, "Name");
protected static final ColumnConfig agencyColumn = new ColumnConfig(properties.agency(), 50, "Agency");
protected static final ColumnConfig dateColumn = new ColumnConfig(properties.date(), 50, "Date");
-
+
+
+
protected Grid grid;
protected ResourceBundle res;