From 3034d7e122adb9751ae51799b3ea1f5993ec1165 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Mon, 15 Dec 2014 11:17:42 +0000 Subject: [PATCH] Fixed filename on export git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-export-widget@102050 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/CSVExportWizardTD.java | 32 +++++----- .../client/CSVWorkSpaceSelectionCard.java | 24 +++++--- .../client/DestinationSelectionCard.java | 59 ++++++++++++++++++- 3 files changed, 87 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVExportWizardTD.java b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVExportWizardTD.java index dc37860..9318d29 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVExportWizardTD.java +++ b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVExportWizardTD.java @@ -1,39 +1,35 @@ package org.gcube.portlets.user.td.csvexportwidget.client; - - import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow; + import com.google.web.bindery.event.shared.EventBus; - - /** * */ -public class CSVExportWizardTD extends WizardWindow { +public class CSVExportWizardTD extends WizardWindow { protected CSVExportSession exportSession; - /** * The id of the {@link CSVTarget} to use. + * * @param targetId */ - - public CSVExportWizardTD(String title, EventBus eventBus) { - super(title,eventBus); - - exportSession= new CSVExportSession(); - - CSVExportConfigCard csvExportConfigCard=new CSVExportConfigCard(exportSession); + + public CSVExportWizardTD(String title, EventBus eventBus) { + super(title, eventBus); + + exportSession = new CSVExportSession(); + + CSVExportConfigCard csvExportConfigCard = new CSVExportConfigCard( + exportSession); addCard(csvExportConfigCard); csvExportConfigCard.setup(); - - + } + - - - + } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVWorkSpaceSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVWorkSpaceSelectionCard.java index a0fc075..e5f75f1 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVWorkSpaceSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/CSVWorkSpaceSelectionCard.java @@ -53,10 +53,18 @@ public class CSVWorkSpaceSelectionCard 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.csv"); + fileName.setValue(fileN+".csv"); p.add(new FieldLabel(fileName, "File Name"), new VerticalLayoutData(-1, -1)); @@ -78,7 +86,6 @@ public class CSVWorkSpaceSelectionCard extends WizardCard { wpanel.setSelectableTypes(lItemType); wpanel.addSelectionHandler(new ItemSelectionHandler() { - public void onSelection(ItemSelectionEvent event) { item = event.getSelectedItem(); Log.debug("Selected Item:" + item); @@ -122,11 +129,11 @@ public class CSVWorkSpaceSelectionCard extends WizardCard { if (exportSession.getItemId() != null) { exportSession.setFileName(fileName.getCurrentValue()); - exportSession.setFileDescription(fileDescription.getCurrentValue()); + exportSession.setFileDescription(fileDescription + .getCurrentValue()); goNext(); } else { - d = new AlertMessageBox("Attention", - "No folder selected"); + d = new AlertMessageBox("Attention", "No folder selected"); d.addHideHandler(hideHandler); d.setModal(false); d.show(); @@ -182,11 +189,12 @@ public class CSVWorkSpaceSelectionCard extends WizardCard { } protected void goNext() { - CSVOperationInProgressCard csvOperationInProgressCard = new CSVOperationInProgressCard(exportSession); + CSVOperationInProgressCard csvOperationInProgressCard = new CSVOperationInProgressCard( + exportSession); getWizardWindow().addCard(csvOperationInProgressCard); - Log.info("NextCard CSVOperationInProgressCard"); + Log.info("NextCard CSVOperationInProgressCard"); getWizardWindow().nextCard(); - + } } diff --git a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/DestinationSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/DestinationSelectionCard.java index fdc69ea..b46aee2 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/DestinationSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvexportwidget/client/DestinationSelectionCard.java @@ -5,15 +5,22 @@ package org.gcube.portlets.user.td.csvexportwidget.client; +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; 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.gwtservice.shared.tr.TabResource; +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; @@ -37,9 +44,16 @@ public class DestinationSelectionCard extends WizardCard { super("CSV destination selection", ""); thisCard=this; this.exportSession = exportSession; + // Default exportSession.setDestination(workspaceDestination); - + + + retrieveTabularResource(); + + } + + protected void create(){ VerticalPanel destinationSelectionPanel = new VerticalPanel(); destinationSelectionPanel.setStylePrimaryName(res.wizardCSS() .getImportSelectionSources()); @@ -98,10 +112,51 @@ 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() {