diff --git a/src/main/java/org/gcube/portlets/user/td/jsonexportwidget/client/DestinationSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/jsonexportwidget/client/DestinationSelectionCard.java index 356b0e2..ec54f6b 100644 --- a/src/main/java/org/gcube/portlets/user/td/jsonexportwidget/client/DestinationSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/jsonexportwidget/client/DestinationSelectionCard.java @@ -5,15 +5,22 @@ package org.gcube.portlets.user.td.jsonexportwidget.client; +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.destination.FileDestination; import org.gcube.portlets.user.td.gwtservice.shared.destination.WorkspaceDestination; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HasValue; import com.google.gwt.user.client.ui.VerticalPanel; import com.sencha.gxt.core.client.util.ToggleGroup; @@ -39,7 +46,12 @@ public class DestinationSelectionCard extends WizardCard { this.exportSession = exportSession; // Default exportSession.setDestination(workspaceDestination); - + + retrieveTabularResource(); + + } + + protected void create(){ VerticalPanel destinationSelectionPanel = new VerticalPanel(); destinationSelectionPanel.setStylePrimaryName(res.wizardCSS() .getImportSelectionSources()); @@ -100,8 +112,48 @@ public class DestinationSelectionCard extends WizardCard { }); setContent(destinationSelectionPanel); + forceLayout(); + } + + + protected void retrieveTabularResource() { + TDGWTServiceAsync.INSTANCE + .getTabResourceInformation(new AsyncCallback() { + + public void onSuccess(TabResource result) { + Log.info("Retrived TR: " + result.getTrId()); + exportSession.setTabResource(result); + create(); + } + + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + showErrorAndHide("Error Locked", + caught.getLocalizedMessage(), "", + caught); + } else { + showErrorAndHide( + "Error", + "Error retrienving tabular resource info: ", + caught.getLocalizedMessage(), caught); + + } + } + + } + + }); } + @Override public void setup() { diff --git a/src/main/java/org/gcube/portlets/user/td/jsonexportwidget/client/JSONWorkSpaceSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/jsonexportwidget/client/JSONWorkSpaceSelectionCard.java index 2e361e9..5b76ceb 100644 --- a/src/main/java/org/gcube/portlets/user/td/jsonexportwidget/client/JSONWorkSpaceSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/jsonexportwidget/client/JSONWorkSpaceSelectionCard.java @@ -57,10 +57,18 @@ public class JSONWorkSpaceSelectionCard extends WizardCard { p = new VerticalLayoutContainer(); formPanel.setWidget(p); + String fileN = "Name"; + if (exportSession.getTabResource() != null + && exportSession.getTabResource().getName() != null && + !exportSession.getTabResource().getName().isEmpty()) { + fileN=exportSession.getTabResource().getName(); + fileN=fileN.trim(); + } + fileName = new TextField(); fileName.setAllowBlank(false); fileName.setWidth("410px"); - fileName.setValue("filename.json"); + fileName.setValue(fileN+".json"); p.add(new FieldLabel(fileName, "File Name"), new VerticalLayoutData(-1, -1));